types.Float.tochar
Method on every
floatConverts the float to a one-character string, treating it as a character code.
Return value
A string of length 1. The float is truncated toward zero first (the same truncation tointeger does), then cast to char, so the fractional part never affects the result: (65.0).tochar() and (65.9).tochar() both give "A".
Notes
Takes no arguments. See types.Integer.tochar for the modulo-256 wraparound, which applies here too once the value is truncated.
Example
println("(65.0).tochar() =", (65.0).tochar())
println("(65.9).tochar() =", (65.9).tochar()) // the fractional part is dropped before the char castOutput:
(65.0).tochar() = A
(65.9).tochar() = ASee also
tochar | Converts the integer to a one-character string, treating it as a character code. |
tochar | Converts the bool to a one-character string, treating it as a character code. |
tointeger | Converts the float to an integer. |
| float | class index |