-
Notifications
You must be signed in to change notification settings - Fork 14
Floating Point
Yuki Kimoto edited this page Apr 29, 2024
·
3 revisions
SPVM uses C functions strtof
and strtod
to produce a floating point from SPVM floating point literal.
But the functions to produce a floating point can be different in strtof
(or strtod
) and C floating point literal.
See the following article about the reason. This is Windows document, but the reason is the same as on Linux.
https://learn.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=msvc-170
# inf, 1.#INF, etc
my $inf = 1.0 / 0.0;
warn $inf;
# nan, -nan, 1.#IND, etc
my $nan = 0.0 / 0.0;
warn $nan;
See the following topic for the reason.
Because the floating-point output problem is complex, SPVM chose not to solve it.