floatStringToInt

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)

bool
floatStringToInt
(
T = ulong
)
(,
out T value
,
size_t decimal_points = 0
)

Parameters

T

type of the integer

float_str cstring

floating point number string to parse

value T

out parameter containing the result

decimal_points size_t

amount of decimal points to consider

Return Value

Type: bool

true if the parsing was successful, else false

Meta