[erlang-questions] BSON parsing?

Carsten Bormann cabo@REDACTED
Fri May 16 01:09:25 CEST 2014


On 15 May 2014, at 13:35, Loïc Hoguin <essen@REDACTED> wrote:

> Erlang doesn't have a representation for NaN, +infinity and -infinity. They should probably be represented as atoms instead.

Ran into the same limitation with excbor.  I used tuples to represent them, to keep the three values related:

  def decode_non_finite(0, 0), do: {CBOR.Tag, :float, :inf}
  def decode_non_finite(1, 0), do: {CBOR.Tag, :float, :"-inf"}
  def decode_non_finite(_, _), do: {CBOR.Tag, :float, :nan}

(where the two parameters are the sign and the mantissa).

Grüße, Carsten




More information about the erlang-questions mailing list