From 5adbd7d22bccc57e17ed00cac09fe8a336bb39c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Wei=C3=9Fl?= Date: Fri, 14 Jun 2013 15:23:59 +0200 Subject: Fix binary matching on floating point middle-endian machines This complements 933e701 (OTP-10209). Without this patch the test case "bs_match_misc_SUITE:t_float/1" fails. Simple error example: 1> <<_,_,_,_,_,_,_,_>> = <<1.25/float>>. <<63,244,0,0,0,0,0,0>> 2> <<1.25/float>> = <<63,244,0,0,0,0,0,0>>. ** exception error: no match of right hand side value <<63,244,0,0,0,0,0,0>> The additional test case is added because in a former version of this patch the ERTS_FP_ERROR_THOROUGH check for NaN/infinity was mistakenly applied on the still word-switched double. --- lib/debugger/test/bs_match_misc_SUITE.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/debugger/test') diff --git a/lib/debugger/test/bs_match_misc_SUITE.erl b/lib/debugger/test/bs_match_misc_SUITE.erl index 6b66c45448..54fa9a59df 100644 --- a/lib/debugger/test/bs_match_misc_SUITE.erl +++ b/lib/debugger/test/bs_match_misc_SUITE.erl @@ -26,7 +26,7 @@ kenneth/1,encode_binary/1,native/1,happi/1, size_var/1,wiger/1,x0_context/1,huge_float_field/1, writable_binary_matched/1,otp_7198/1, - unordered_bindings/1]). + unordered_bindings/1,float_middle_endian/1]). -include_lib("test_server/include/test_server.hrl"). @@ -36,7 +36,7 @@ all() -> [bound_var, bound_tail, t_float, little_float, sean, kenneth, encode_binary, native, happi, size_var, wiger, x0_context, huge_float_field, writable_binary_matched, - otp_7198, unordered_bindings]. + otp_7198, unordered_bindings, float_middle_endian]. groups() -> []. @@ -106,6 +106,13 @@ t_float(Config) when is_list(Config) -> ok. +float_middle_endian(Config) when is_list(Config) -> + F = 9007199254740990.0, % turns to -NaN when word-swapped + ?line fcmp(F, match_float(<>, 64, 0)), + ?line fcmp(F, match_float(<<1:1,F:64/float,127:7>>, 64, 1)), + ?line fcmp(F, match_float(<<1:13,F:64/float,127:3>>, 64, 13)), + ok. + fcmp(F1, F2) when (F1 - F2) / F2 < 0.0000001 -> ok. -- cgit v1.2.3