Prev | Current Page 84 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Part I: The Core Language
32
Floating - Point Numbers
Float s represent numbers that contain a decimal point even if they are whole numbers. This is
important, as 10.0 is quite different from 10 and must be stored appropriately. If you feel that a round
number will need to support fractions of a number, then it helps to plan for this in advance and choose
to use a Float .
haXe provides a lot of help with choosing which type to use, thanks to type inference. When you use
constant numerical values within an expression, haXe automatically converts non - floating values ??” or
integers ??” to Float s where necessary. Likewise, any Float s containing a trailing 0 may be converted to
an integer if the expression warrants it.
In haXe, Float s are of the double precision IEEE specification utilizing 64 bits (8 bytes). This is the
standard for many languages and gives extremely high precision. This same precision is carried to all
three of the platforms supported by haXe, so you can be sure that you will receive similar results
regardless of your target platform.


Pages:
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96