Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of the float2string intrinsic #785

Open
larshum opened this issue Sep 14, 2023 · 0 comments
Open

Behavior of the float2string intrinsic #785

larshum opened this issue Sep 14, 2023 · 0 comments

Comments

@larshum
Copy link
Contributor

larshum commented Sep 14, 2023

The float2string intrinsic is implemented in the OCaml backend using the string_of_float function, which prints specific floating-point numbers in an odd format; for example, the value 1.0 is printed as 1. which does not conform to the JSON standard (#784). In addition, we have existing tests that assume this particular behavior (in arg.mc and csv.mc), which leads to difficulties when implementing the intrinsic in other backends where the standard print functions use a different format (@asta12 has failing tests due to this in the JVM backend).

As suggested in #784, an alternative could be to use the Printf module of OCaml to print floats instead (I assume that would be something like Printf.sprintf "%f" instead of string_of_float). However, this results in what I would argue to be uglier prints (the value 1.0 is printed as 1.000000 instead of 1.). Implementing it natively in Miking could be an alternative, but since we don't currently have bitwise operations (to access the mantissa and exponent), it's not a viable option at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant