diff options
author | Steve Vinoski <[email protected]> | 2010-05-29 12:07:32 -0400 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-06-07 13:23:57 +0200 |
commit | a6a8805b906dc9be2ec3ecba647997335e345182 (patch) | |
tree | fa61cc878d822255dfeb9603ad79f6d765297912 /lib/erl_interface/src/encode/encode_double.c | |
parent | 1222a9ce643ef287debdb6c76939eceb12ef0c7d (diff) | |
download | otp-a6a8805b906dc9be2ec3ecba647997335e345182.tar.gz otp-a6a8805b906dc9be2ec3ecba647997335e345182.tar.bz2 otp-a6a8805b906dc9be2ec3ecba647997335e345182.zip |
compact IEEE 754 double encoding in external binary format for ei
Implement the compact IEEE 754 double encoding in external binary
format for ei. Encoding for ei now always produces the NEW_FLOAT_EXT
format. Decoding and term printing handle both the old ERL_FLOAT_EXT
encoding and the new NEW_FLOAT_EXT encoding. Legacy erl_interface code
also handles the new encoding, but still produces the ERL_FLOAT_EXT
encoding by default.
Also enable the DFLAG_NEW_FLOATS distribution flag.
Reduce the number of copies of the code for encoding and decoding
doubles throughout ei and erl_interface by instead calling the ei
encoding and decoding functions wherever possible.
Restore commented-out float tests in ei_decode_SUITE and
ei_encode_SUITE in lib/erl_interface/test. Modify them to make them
match the style of other tests in the same suites.
These changes are based on an ei float patch from Serge Aleynikov
originally submitted against R12B-2 in July 2008.
Diffstat (limited to 'lib/erl_interface/src/encode/encode_double.c')
-rw-r--r-- | lib/erl_interface/src/encode/encode_double.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/erl_interface/src/encode/encode_double.c b/lib/erl_interface/src/encode/encode_double.c index 53f3d52ba6..1c8cb286f5 100644 --- a/lib/erl_interface/src/encode/encode_double.c +++ b/lib/erl_interface/src/encode/encode_double.c @@ -27,13 +27,13 @@ int ei_encode_double(char *buf, int *index, double p) char *s = buf + *index; char *s0 = s; - if (!buf) s ++; + if (!buf) + s += 9; else { - put8(s,ERL_FLOAT_EXT); - memset(s, 0, 31); - sprintf(s, "%.20e", p); + /* IEEE 754 format */ + put8(s, NEW_FLOAT_EXT); + put64be(s, ((FloatExt*)&p)->val); } - s += 31; *index += s-s0; |