Since "Boolean" (at least in VB and other languages) values (True vs False) where:
False = 0
True = NON - Zero
Excluding the ranges of DWORD vs Longs where:
DWORD range of 0 to 4,294,967,295 ( 0 to 2^32-1)
LONG range, from -2,147,483,648 to +2,147,483,647 ( -2^31 to 2^31 - 1)
Is there an advantage or disadvantage of a variable being declared as DWORD or LONG? Besides personal preference (or a possible value returned that does not fall within the correct range for TRUE?)
I keep catching myself porting VB to PB and sometimes I use LONG, sometimes I use DWORD for a "Boolean" reply depending on my mood, or thought process at the moment, or phase of the moon or something.
Later it gets confusing because I wonder when I wrote it "Why did I declare it that way"? so I would like to break that habit.
The only drawback would be if the variable were to hold the value of something I did not write (like an API, or someone elses dll) so then of course it would have to be of the same type as the type. but if it were my type, then it would be 0 or 1 so I am not worried about the actual values returned at the moment, but more advantages/disadvantages since both take 4 bytes, its the ranges that vary.
False = 0
True = NON - Zero
Excluding the ranges of DWORD vs Longs where:
DWORD range of 0 to 4,294,967,295 ( 0 to 2^32-1)
LONG range, from -2,147,483,648 to +2,147,483,647 ( -2^31 to 2^31 - 1)
Is there an advantage or disadvantage of a variable being declared as DWORD or LONG? Besides personal preference (or a possible value returned that does not fall within the correct range for TRUE?)
I keep catching myself porting VB to PB and sometimes I use LONG, sometimes I use DWORD for a "Boolean" reply depending on my mood, or thought process at the moment, or phase of the moon or something.
Later it gets confusing because I wonder when I wrote it "Why did I declare it that way"? so I would like to break that habit.
The only drawback would be if the variable were to hold the value of something I did not write (like an API, or someone elses dll) so then of course it would have to be of the same type as the type. but if it were my type, then it would be 0 or 1 so I am not worried about the actual values returned at the moment, but more advantages/disadvantages since both take 4 bytes, its the ranges that vary.
Comment