types.Float.tofloat
Method on every
floatReturns the float itself.
Return value
this, unchanged. Nothing is lost, unlike types.Integer.tofloat, which can round a 64-bit integer down to what a 32-bit SQFloat can represent.
Notes
Takes no arguments. Provided so every numeric type answers the same tointeger/tofloat pair without the caller checking which one it already has.
Example
// tofloat() on a float is the identity conversion: no rounding happens here,
// unlike Integer.tofloat() converting a value from a wider integer range.
println("(3.5).tofloat() =", (3.5).tofloat())
println("(3.5).tofloat() == 3.5 =", (3.5).tofloat() == 3.5)
println("type((3.5).tofloat()) =", type((3.5).tofloat()))Output:
(3.5).tofloat() = 3.5
(3.5).tofloat() == 3.5 = true
type((3.5).tofloat()) = floatSee also
tofloat | Converts the integer to a float. |
tointeger | Converts the float to an integer. |
tofloat | Converts the bool to a float. |
| float | class index |