Prev | Current Page 152 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


The haXe Math class provides some more controlled methods for converting a Float to an Int . These
include floor , ceil , and round .
The floor method performs the same functionality as casting a Float to an Int , rounding the floating
point value down to the nearest whole integer:
var myInt : Int = Math.floor(myFlt);
Part I: The Core Language
66
The ceil method, or ceiling performs the opposite functionality by rounding a floating point value up
to the nearest integer, while the remaining method, round , will round the value up if the mantissa is
equal to or larger than .5 and down if the mantissa is less than .5 in Flash and JavaScript and will round
up if the mantissa is larger than .5 and down if the mantissa is less than or equal to .5 in Neko.
Using String Functions
Three classes of functions are provided by the haXe library for manipulating String s. The most
common of the string functions are contained within the String class itself, while the less useful
functions can be found in the StringTools class.


Pages:
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164