bignum support in ei?

Vance Shipley vances@REDACTED
Thu Jun 12 00:16:22 CEST 2003


How do I receive a bignum in ei?  Using ei_decode_long() doesn't work.

When I send integers and use ei_print_term() to see what was received
and ei_get_type() to see the type I get the following:

Sent              Received                           Type
----------------  ---------------------------------  ---------------------
16#00000000       0                                  ERL_SMALL_INTEGER_EXT
16#00000001       1                                  ERL_SMALL_INTEGER_EXT
16#000000ff       1                                  ERL_SMALL_INTEGER_EXT
16#000001ff       65535                              ERL_INTEGER_EXT
16#00ffffff       16777215                           ERL_INTEGER_EXT
16#07ffffff       134217727                          ERL_INTEGER_EXT
16#08ffffff       #integer(2) = {65535,2303}         ERL_SMALL_BIG_EXT
16#ffffffff       #integer(2) = {65535,65535}        ERL_SMALL_BIG_EXT
16#fffffffffffff  #integer(3) = {65535,65535,65535}  ERL_SMALL_BIG_EXT

Seems like a strange place to make the last break but anyway.

The ei_get_type() function returns a size of 0 for ERL_SMALL_INTEGER_EXT
and ERL_INTEGER_EXT but when the type is ERL_SMALL_BIG_EXT size is the
number of elements in the tuple.  There is also an ERL_LARGE_BIG_EXT 
type defined but I don't know how big a number you need to get it.

I see from the source that there is an ei_decode_bignum() however it is
noted that it just skips past it.

	-Vance




More information about the erlang-questions mailing list