Getting a STRING from a NUMERIC object

NUMERIC to STRING

Every class has the out method that can be used to get a text version of the object. For a lot of classes, this method returns internal information that is not really useful for the end user. But for every NUMERIC class, the out method returns a text representation of the number that the NUMERIC object represents.

print_integer (a_integer: INTEGER) -- Print the value of `a_integer`. do print (a_integer.out + "%N") end

Note that for more advanced conversion, you can also use a conversion class like FORMAT_DOUBLE.

STRING to NUMERIC

The reverse conversion is available for all standard numeric types (INTEGER_8, INTEGER_16, etc.) using the features to_integer_8, to_integer_16, etc. of class STRING. The string should contain a valid string representation of the corresponding numeric value. This can be checked by calling is_integer_8, is_integer_16, etc. before calling the conversion functions.

cached: 12/21/2024 12:00:17.000 PM