[erlang-questions] C interface, NaN and infinity

David Welton davidnwelton@REDACTED
Fri Dec 5 22:17:55 CET 2014


Hi,

> Ok, so you are talking about distribution and erl_interface.
>
> If I'm understanding you correctly: You have a C-Node using legacy
> erl_interface, encoding a NaN double and sending it to the beam? It has
> nothing to do with beam?

> Did you actually manage to get a NaN to the beam or does beam always close
> the connection?

It always rejected it as having a bad term.

> Regarding erl_interface, i think neither erl_mk_float (old) or
> ei_encode_double (new) checks if it is a valid double. The easiest solution
> is probably to check the double yourself with isfinite() before encoding.
> Regardless, beam should drop the connection (the distribution channel) if it
> finds bad data on the wire. As it does in your example.

Our C++ guy he was checking and double checking his code and wondering
why it was causing an error on the Erlang side - an error that doesn't
actually give you a lot of information on what went wrong unless you
take apart the binary it shows, byte by byte.

It would have been much simpler had the C code indicated that it was
not possible to encode the value, which, from the C side of things,
was a legitimate float.

-- 
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/



More information about the erlang-questions mailing list