[erlang-questions] erlang vs java floating point format

David Hopwood david.hopwood@REDACTED
Fri Aug 31 17:06:59 CEST 2007


Ryan Rawson wrote:
> Note that java floats are almost but not quite IEEE 754 floats.

Assuming strictmath is in effect, and excluding NaN payloads and
signalling NaNs, how are they different?

> On Aug 30, 2007, at 9:56 AM, "Dave Rafkind" <dave.rafkind@REDACTED> wrote:
> 
>> Hello great list!
>>
>> I am a newcomer to Erlang, so perhaps this is an easy question:
>>
>> If I send a java float to an Erlang process over TCP, I can match
>> against the resulting four bytes with something like
>>
>> <<FloatNumberFromJava:32/signed-big-float>>
>>
>> This seems to indicate that Erlang and Java floating point formats are
>> the same (at least for my setup which is Erlang 5.5.4, java 1.5 on an
>> Intel/Linux box), which is
>> IEEE 754:
>> http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3
>>
>> My question is, can this be reliably depended on to work across all
>> versions of Erlang and java and all supported architectures?

It will work on any platform for which the C ABI defines floats to be
in IEEE 754 format. I don't know whether that is all architectures
supported by Erlang/OTP.

-- 
David Hopwood <david.hopwood@REDACTED>




More information about the erlang-questions mailing list