simple float query
BlitzMax Forums/BlitzMax Beginners Area/simple float query
| ||
I'm convinced I'm doing something fundamentally wrong here. Please someone put me out of my misery!Global dave:Float = (600/155) Print dave Gives an output of 3.00000000 Why not 3.87? Thanks (and apologies for the stupidity!) |
| ||
Global dave:Float = (600/155.0) Print dave Mfg Suco |
| ||
As above. When you specify a `number` in BlitzMax, you are basically defining a CONST (constant). If you don't provide any decimal portion of any kind it assumes it is an integer. If you provide a decimal even if it's .0 it will make it into a float constant. The math obviously differs depending on the type. 600/155 in integer math ignores the fractional part of the result. So as Suco-X said, just add .something to the end of the number and you'll clue Blitz in to know to make it a floating point sum. You only have to add .0 to one of the numbers because that overrides the type of the other number. |
| ||
Thanks for that. Dave. |