floating-point representation
david wallin
david@REDACTED
Thu Jun 7 23:58:52 CEST 2001
I tried to decipher my own mail and think some clarification might be
in order...
>Hi all,
>
>I'm trying to create (32-bit) floats from binaries (using the bit syntax).
>
>Empirical tests showed this to be a naive idea :
>
>A = random:uniform(256),
>B = random:uniform(256),
>C = random:uniform(256),
>D = random:uniform(256),
>
><<Float:32/signed-float>> = <<A, B, C, D>>.
>
>(depending on the values of A,B,C,D ; this can result in a badmatch).
This is probably bit-combinations meaning "Infinity" and "NaN". It
would be nice if this operation didn't fail but instead returned the
above. (Is this possible and/or is it a performance penalty for this
?)
>
>What kind of representation is used for floats (is this a local issue) ?
>
>Also, is there any way to tell what precision that erlang uses ?
>
>
>--david.
More information about the erlang-questions
mailing list