Parses a floating point number represented as a string directly to an integer value.
To represent the fractional part we multiply the value by the requested amount of decimal points and add it up. For example:
"1.123" -> 1123 (decimal_points = 3) "0.01" -> 10 (decimal_points = 3)
Any characters longer than the requested amount of decimal points will be cut off:
"1.2345" -> 123 (decimal_points = 2) "10.2030" -> 1020 (decimal_points = 2)
"1.2345" -> 1 (decimal_points = 0) "10.2030" -> 10 (decimal_points = 0)
type of the integer
floating point number string to parse
out parameter containing the result
amount of decimal points to consider
true if the parsing was successful, else false
See Implementation
Parses a floating point number represented as a string directly to an integer value.
To represent the fractional part we multiply the value by the requested amount of decimal points and add it up. For example:
"1.123" -> 1123 (decimal_points = 3) "0.01" -> 10 (decimal_points = 3)
Any characters longer than the requested amount of decimal points will be cut off:
"1.2345" -> 123 (decimal_points = 2) "10.2030" -> 1020 (decimal_points = 2)
"1.2345" -> 1 (decimal_points = 0) "10.2030" -> 10 (decimal_points = 0)