dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 0 forks source link

In tests, compare optimized and non optimized compiled and interpreted results #226

Closed dplassgit closed 10 months ago

dplassgit commented 1 year ago

This is running into issues with printing doubles. The default Java to-string prints doubles nicely, e.g., 3.0 and 3.14159 but sprintf (clib) can only either print 3 and 3.14159 OR 3.000000 and 3.141590. There's no "always include the decimal and at most one zero" option.

dplassgit commented 11 months ago

https://stackoverflow.com/questions/54370268/java-style-printing-of-double-in-c https://stackoverflow.com/questions/6826556/printing-a-double-without-the-decimal-places

Maybe use %g?

dplassgit commented 10 months ago

The sticking point is that Java (optimizer) by default includes a trailing .0 for "round" floats, but %g never does. Ideally, we would include a trailing .0 so as to distinguish floats from ints when printing. (That's tracked in issue #273)