-
Notifications
You must be signed in to change notification settings - Fork 17
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
Portability issue with float serialization #2
Comments
The reason for this choice was performance, but maybe the gain is not that significant. Some benchmarks are needed. FYI, I submitted a feature request some time ago without much of a conclusion; feel free to add your insights: http://caml.inria.fr/mantis/view.php?id=5494 |
I made the following lazification: let float_endianness = lazy (
match String.unsafe_get (Obj.magic 1.0) 0 with
'\x3f' -> `Big
| '\x00' -> `Little
| _ -> assert false
) It's the simplest solution I can think of. I hope it solves the Yojson/Js_of_ocaml problem. |
Thanks a lot! Unfortunately, this is still not quite enough, as there is a piece of code a bit later in the same file (around line 256) that calls read_untagged_float64 and write_untagged_float64 unconditionally to test whether they work properly... |
Oops. This one is now fixed (tag v.1.0.5). Hopefully it's the last one. |
Several people have tried to use Yojson, which depends on Biniou, with Js_of_ocaml. However, Biniou uses an unportable hack to serialize floats. In particular, the expression "String.unsafe_get (Obj.magic 1.0) 0" is unconditionnally executed and fails when compiled to Javascript. Maybe the function Int64.of_float could be used instead to access the binary representation of floats?
The text was updated successfully, but these errors were encountered: