AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.94k stars 664 forks source link

Think about aligning `dtoa` with JS behavior (also toFixed?) #1163

Open dcodeIO opened 4 years ago

dcodeIO commented 4 years ago

While implementing WASI's trace I noticed that we currently don't have the utility in place to omit trailing decimal .0s when converting a float to a string, like JS would do. As a result, WASI's trace prints those decimal places, while JS's trace does not.

trace("hello world", 3, 1, 2, 3.5);
// trace: hello world 1.0 2.0 3.5

This looks like it is not quite the same but similar in nature to toFixed, and looking into both instead of implementing workarounds might be ideal.

torch2424 commented 3 years ago

Oops, I just ran into the missing .toFixed today :joy: No worries though! I don't actually "need" it. But I'm commenting here, so I can remember to open a PR for it if I get the time :smile: