Use of decimal values in coding

Is it acceptable to use a decimal value in coding, or is that generally frowned upon? I’m looking at a looped event with a timer. I’ve already coded several branches, and now I have a section where I want the events to count for half as much time. Rather than descending into coding convolutions, or going back and adjusting all the other values, am I all right to do something like:

*label pets_time
  #Play with the puppy.
    *set timer + 0.5
    He's so adorable!
    *goto pets_time
  #Pet the kittens.
    *set timer + 0.5
    There are six kittens, and they mob you for attention. The black one rolls over on her back, little paws waving in the air.
    *goto pets_time
  #Be spastic with the ferret.
    *set timer + 0.5
    The ferret runs round and round in circles, over and over, sending a spray of wood shavings into the air.
    *goto pets_time
  #Talk to the myna bird.
    *set timer + 0.5
    "Polly want a cracker?"

    "My name is Elisheva! My name is Elisheva!" the bird caws back at you.
    *goto pets_time
  #Move on.
    *if (timer > 6)
      *goto on_with_the_show
      *goto main_choice_tree

Will that work, or are decimals generally not done? I should mention, it’s for the piece I hope to enter in the CoG contest.


I used decimals in, weirdly enough, the commentary for Midsummer. It worked fine.


I’m pretty sure it’s perfectly fine, as long as you don’t forget that you won’t always have an integer (e.g. the time could be 0.5 1.5 etc.)

If you mean does it work? Then yes-- they allow for both integer, floating points (decimals), negative and 0 values, so you should be 'aight.


I’ve used decimals. It’s not ideal, but it works. (edit: and by “works” I mean “is about to be published.”)


@Gower Ah, good to know; thanks!

@fairlyfairfighter Sorry, I probably wasn’t clear. I knew it worked as in ‘does this function effectively’. My concern was more, ‘will this be frowned upon by editors and others who monitor and set CoG’s style parameters’—in other words, is it an acceptable convention.

@Havenstone Not ideal as in ‘worth the time to go change the system to suit integer-only’…ah, thanks for clarifying. Not ideal as in ‘next time I make a timer I should plan better’, then? Very good. Thanks!


So, does anyone know how CoG deals with floating point errors? :thinking:

1 Like

I mean I believe they’d prefer integers, and as a beta tester occasionally (nowhere near an extraordaniare, though :wink:) integers would be slightly better, but I don’t think it’d make a massive difference, and probably not worthwhile to change if already done.
Good luck with your code/ game, and I hope it all goes to plan.

1 Like