WebAssembly / wabt

The WebAssembly Binary Toolkit
Apache License 2.0
6.55k stars 675 forks source link

c-writer.cc: represent float consts as integer literals #2389

Open keithw opened 4 months ago

keithw commented 4 months ago

Fixes #2388 by representing float constants as reinterpretations of an integer. This seems a bit safer than using a decimal %.9g or %.17g literal, and allows us to remove some special-case handling of NaNs, infinity, and negative zero. It does bloat the output a bit (we could shorten f64_reinterpret_i64 to something like f64i which would help a little).

wasm2c (on MSVC) now passes the new proposed testcases (https://github.com/WebAssembly/wabt/actions/runs/7864206734/job/21455684596 vs. https://github.com/WebAssembly/wabt/actions/runs/7864260678/job/21455793263).

SoniEx2 commented 1 month ago

it would be nice to get this merged...