Eight, Nine, Ten...

Started by
31 comments, last by Khatharr 11 years ago

Excerpt from code I recently saw:


#define EIGHT  (0x08) 
#define NINE   (0x09) 
#define TEN    (0x10) 

. . .

I hope I wasn't too subtle - the definition of TEN is what is ... interesting here.

Advertisement

Good thing they put parentheses around those literals!

edit:

Oh gosh, I didn't even realize the TEN issue... That's horrible.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

edit:
Oh gosh, I didn't even realize the TEN issue... That's horrible.

That edit made my day :D - that is exactly why this is so scary.

an explanation for the more noobish of us? what's wrong with that definition? >_<;

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

an explanation for the more noobish of us? what's wrong with that definition? >_<;

0x10 in 16 in hex.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Could be binary coded decimal... and it makes outputting a text value easier as well ;)

Manic Miner on the ZX Spectrum didn't even store the game score or high score in a variable... it just used ASCII text on the screen (the screen area where the score was displayed was never cleared).

The algorithm only added to your score either 1 or 10 or 100 at a time IIRC. It just increased the ASCII value at the screen position by 1 and if that makes it > 9 it made the current digit 0 and added 1 to the next digit along (and looped if that was bumped to > 9 as well).

It then just copied the score to the high score location if the score was larger than the current high score (check was done with another ASCII comparison).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Could be binary coded decimal... [snip]

That sounds so convoluted it requires its own thread.

Unfortunately that wasn't the case here - this code, according to a colleague who originally fixed it - caused a fatal crash in the software.

Obvious, the coder has 8 fingers on each hand

Obvious, the coder has 8 fingers on each hand

... maybe the use of named constants is what was at fault here ...

...
#define FOURTY_TWO (042)
#define NINETEEN_EIGHTY_FOUR (NINETEEN, EIGHTY, FOUR)
...

#define FOURTY_TWO (042)

Eurgh. I have many horror stories of Octal gone awry.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement