aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/test/ei_encode_SUITE.erl
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2010-05-29 12:07:32 -0400
committerRaimo Niskanen <[email protected]>2010-06-07 13:23:57 +0200
commita6a8805b906dc9be2ec3ecba647997335e345182 (patch)
treefa61cc878d822255dfeb9603ad79f6d765297912 /lib/erl_interface/test/ei_encode_SUITE.erl
parent1222a9ce643ef287debdb6c76939eceb12ef0c7d (diff)
downloadotp-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/test/ei_encode_SUITE.erl')
-rw-r--r--lib/erl_interface/test/ei_encode_SUITE.erl20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/erl_interface/test/ei_encode_SUITE.erl b/lib/erl_interface/test/ei_encode_SUITE.erl
index fb790eb7c3..dd6f37e453 100644
--- a/lib/erl_interface/test/ei_encode_SUITE.erl
+++ b/lib/erl_interface/test/ei_encode_SUITE.erl
@@ -181,20 +181,14 @@ test_ei_encode_misc(Config) when is_list(Config) ->
?line <<131>> = get_binaries(P),
-% ?line {term,F} = get_term(P),
-% ?line match_float(F, 0.0),
-% ?line {term,F} = get_term(P),
-% ?line match_float(F, 0.0),
+ ?line {<<70,_:8/binary>>,F0} = get_buf_and_term(P),
+ ?line true = match_float(F0, 0.0),
-% ?line {term,F} = get_term(P),
-% ?line true = match_float(F, -1.0),
-% ?line {term,F} = get_term(P),
-% ?line true = match_float(F, -1.0),
+ ?line {<<70,_:8/binary>>,Fn1} = get_buf_and_term(P),
+ ?line true = match_float(Fn1, -1.0),
-% ?line {term,F} = get_term(P),
-% ?line true = match_float(F, 1.0),
-% ?line {term,F} = get_term(P),
-% ?line true = match_float(F, 1.0),
+ ?line {<<70,_:8/binary>>,Fp1} = get_buf_and_term(P),
+ ?line true = match_float(Fp1, 1.0),
?line {<<100,0,5,"false">>,false} = get_buf_and_term(P),
?line {<<100,0,4,"true">> ,true} = get_buf_and_term(P),
@@ -310,6 +304,8 @@ get_term(P) ->
%%
+match_float(F, Match) when is_float(F), is_float(Match), F == Match ->
+ true;
match_float(F, Match) when is_float(F), F > Match*0.99, F < Match*1.01 ->
true.