why for exemple is 139 multiplied by 256 issue an overflow while 143 multiplied by 65536 doesn't.
Printable View
why for exemple is 139 multiplied by 256 issue an overflow while 143 multiplied by 65536 doesn't.
I think everyone stumbles across this sooner or later.
it's because VB assumes 256 and 139 are integers and therefore can only be up to 32,767.
if you force one to be a long it's OK
eg. 139 * clng(256)
Maybe VB is actually trying to optimise!
thank for the hint Mark.
Keep you math in declared vars and constants so you know what types you're dealing with, numbers don't tell you enough
If you're dealing with really big numbers, you can declare it as Decimal or Currency
Hint and hint, here's the actiul hint:
Declare your values!
Code:?256&*256&
?65536@*65536@