Negative value for variable
-migrated-
Negative value for variable Posted on: 08/07/2011 5:26am
Quote Post
I came across a game where variable is declared with negative value
Code: [Select]
selectedLevel:int = -1;
what does it mean
Re: Negative value for variable Posted on: 08/07/2011 6:24am
Quote Post
Never let a computer tell me shit.
it means that the value is less than 0...

developers (read: "I") typically use negative values as -- generally binary -- semaphores.  This way I can essentially have a flag variable without the resource overhead of an actual additional variable.

in your example it logically means that "no level has _actually_ been selected, so don't run the level selection routines."



I use this AoB tool to make all the AoBs I post. Try the online version if you dont feel like downloading it.
"Obviously, windows are central to Windows. They are so important that they named the operating system after them. But what is a window?"