Negative value for variable
Posted Aug 7, 2011 5:26 am
I came across a game where variable is declared with negative value
Code: [Select]
selectedLevel:int = -1;
what does it mean
-migrated-
2 posts
I came across a game where variable is declared with negative value
selectedLevel:int = -1;
what does it mean
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?"