Floats and decimal places
BlitzMax Forums/BlitzMax Beginners Area/Floats and decimal places
| ||
This thread talked about limiting floats to a number of decimal places... http://www.blitzbasic.com/Community/posts.php?topic=41898 Blitzbasic allowed this... Print Int(variable*100)*.01 (thanks Seth) and also... x#=123.456 y=x*100 z#=y/100.0 ;or * .01 Print z but bmx doesn't play the game. Anybody got a similar shortcut for Max? |
| ||
a#=0.234252341 print a[0..3] |
| ||
OK, so it's...a#=0.234252341 number:string = a# print number[0..4] thanks |
| ||
Interesting example! Problem is that it wouldn't help if your String (number) changed in length, so 10.2323 would return different # of dec places than if the # was 1.2323 |
| ||
Print Float(Int(variable*100))*.01 ? |
| ||
teamonkey, I thought that would work but this... variable:Float=13.12345 Print Float(Int(variable*100))*.01 gives me this... 13.1999 etc etc Tried using mod methods which worked in BB but it all comes down to this... b:float = 45.0/100.0 print b This can't be right... can it? **** Ignore me **** It is a bug reported here... http://www.blitzbasic.com/Community/posts.php?topic=42130 |