Can't make decimal consts?
Blitz3D Forums/Blitz3D Beginners Area/Can't make decimal consts?
| ||
I have no idea why this won't work! Was using a constant to set the step size while moving my camera and found it only works when I hard-code the value but when I use a constant. What stupid newbie mistake am I making here? Even when just trying to print it, it won't work: Const WholeNumber=1 Const Decimal=0.1 Graphics3D 800,600 While Not KeyHit(1) Text 320,500,"Whole numbers work: " + Str(WholeNumber) Text 320,550,"..but decimals don't: " + Str(Decimal) Wend |
| ||
Const Decimal#=0.1 |
| ||
Variables by default are integers. Suffix the variable name with # to make it a float or $ to make it a string. If you want to be explicit, % is an integer. I believe it's only necessary to suffix when you first declare the variable, but some people like to use the variable's suffix throughout their code.Const foo# = 0.1 Print foo |
| ||
Ah, didn't realise that was needed for consts. *slaps head* |
| ||
It's needed for Global Local, everything. Unless you state the variable type, blitz assumes it's an integer. Mind you:a = "ross" Works fine :o) |