|
![]() |
||||||||||||||
Primitive Data Types TutorialConversion to Integer TypeFunction asInt(x) converts any non-integer value x to Integer type. Function asInt(x) converts String value x, representing a valid integer, to appropriate Integer value. If x represents a float value, only digits before decimal point are used. Additionally, function ascii(x) converts a string value x to ASCII code of the first character of the string. If x is an empty string, the function result is zero. Function asInt(x) converts Bool value true to integer value 1 and value false to 0. For Float argument, it converts a float value to closest integer. The same behaviour provides function round(x). Function ceil(x) returns closest not smaller integer. Function floor(x) returns closest not larger integer. Source code:{# asInt(3.6), asInt(-3.6), round(3.6), round(-3.6), ceil(3.6), ceil(-3.6), floor(3.6), floor(-3.6), asInt('3'), asInt('3.8'), asInt(true), asInt(false), ascii("abc"), ascii('') #} Result:{# 4, -4, 4, -4, 4, -3, 3, -4, 3, 3, 1, 0, 97, 0 #}
|
|
||||||||||||||
© 2006 Saša Malkov | |||||||||||||||