diff options
| author | LLLL Colonq <llll@colonq> | 2026-03-27 17:23:26 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-03-27 17:23:26 -0400 |
| commit | 4b294e47144da00ae4b9568fed39569d187ce07e (patch) | |
| tree | 179222746330c25fa4f0dfdb03e0fc0a15ad7c9b /src/runtime.c | |
| parent | 3707dfaa64715c8fb1ba8a23f9762fef174538d8 (diff) | |
Fix doubles
Diffstat (limited to 'src/runtime.c')
| -rw-r--r-- | src/runtime.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/runtime.c b/src/runtime.c index a77fbf4..6f3759f 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -212,10 +212,14 @@ double pit_as_double(pit_runtime *rt, pit_value v) { pit_error(rt, "invalid use of value as double"); return 0.0; } - return (double) v; + union { double dval; u64 ival; } x; + x.ival = v; + return x.dval; } pit_value pit_double_new(pit_runtime *rt, double d) { - return pit_value_new(rt, PIT_VALUE_SORT_DOUBLE, (u64) d); + union { double dval; u64 ival; } x; + x.dval = d; + return pit_value_new(rt, PIT_VALUE_SORT_DOUBLE, x.ival); } i64 pit_as_integer(pit_runtime *rt, pit_value v) { |
