aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/num_bif_SUITE.erl
AgeCommit message (Collapse)Author
2018-08-27Fix bug in compact representation of float_to_list/2Serge Aleynikov
2018-06-18Update copyright yearHenrik Nord
2018-04-10erts: Workaround test t_float_to_string for windowsSverker Eriksson
2018-04-04erts: Fix float_to_list(F, [{decimals,D}])Sverker Eriksson
to better conform with io_lib:format("~.*f", [D,F])
2018-01-24Merge branch 'maint'Sverker Eriksson
2018-01-24Merge PR-1684 from sverker/float_to_list-rounding-bug/OTP-14890Sverker Eriksson
Fix rounding bug in float_to_list/2
2018-01-17Merge branch 'maint'Lukas Larsson
2018-01-15erts: Fix float_to_list(F, [{decimals,D}]).Sverker Eriksson
Example symptom: 1> float_to_list(0.145, [{decimals,1}]). "0.2" There were two problems in sys_double_to_chars_fast 1. Most serious was adding 0.55555555 / (10^D) instead of 0.5 / (10^D) which imposed a 5.5% risk of a faulty rounding up. 2. Using fixpoint for frac_part which lost significant bits if F < 0.5
2018-01-03Fail if ':' is passed to binary_to_integer/2Frank Hunleth
Before: 1> binary_to_integer(<<":">>, 16). 3 After: 1> binary_to_integer(<<":">>, 16). ** exception error: bad argument in function binary_to_integer/2 called as binary_to_integer(<<":">>,16) Prior to this change, both list_to_integer/2 and binary_to_integer/2 would convert strings with values between ASCII '9' up to '0'+base for base > 10. For example, when converting in base 16, you could pass ':', ';', '<', '=', '>', and '?' without getting an exception. This was due to a missing check in c2int_is_invalid_char(). This change adds the missing check and a regression test for passing ':'. It also simplifies the code and tightens up an out-of-bounds check to make it off-by-one rather than off-by-two.
2017-10-13Eliminate use of deprecated functions in stringBjörn Gustavsson
2017-05-04Update copyright yearRaimo Niskanen
2017-02-16Merge branch 'maint' into 'master'Sverker Eriksson
2017-02-14erts: Fix round/1 for large floatsSverker Eriksson
1> round(6209607916799025.0). 6209607916799026 Problem: Adding/subtracting 0.5 and large double floats between (1 bsl 52) and (1 bsl 53) does not give reliable results. Solution: Use round() function in math.h.
2017-02-14Fixed typos in ertsAndrew Dryga
2016-09-05Implement the new ceil/1 and floor/1 guard BIFsBjörn Gustavsson
Implement as ceil/1 and floor/1 as new guard BIFs (essentially part of Erlang language). They are guard BIFs because trunc/1 is a guard BIF. It would be strange to have trunc/1 as a part of the language, but not ceil/1 and floor/1.
2016-03-15update copyright-yearHenrik Nord
2016-02-17Eliminate use of test_server.hrl and test_server_line.hrlBjörn Gustavsson
As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl.
2016-02-02Better list_to_integerDmytro Lytovchenko
Now tries to use whole width of signed long (Sint) and this halves amount of multiplications needed to parse long integers. New code is 2-3 times faster than the old code for large inputs (tens and hundreds of digits), behavior should not change for small inputs. Test ran 10k times with GC forced between attempts. Was (R17): 720 el base 10: 0.14682 sec; base 16: 0.192722 sec; base 36: 0.337118 sec. 2800 el base 10: 1.794133 sec; base 16: 2.735106 sec; base 36: 4.761108 sec. 6500 el base 10: 9.316434 sec; base 16: 14.109469 sec; base 36: 25.319263 sec. Now (R19 Dev) 720 el base 10: 0.10265 sec; base 16: 0.10851 sec; base 36: 0.160478 sec. 2800 el base 10: 1.002793 sec; base 16: 1.360649 sec; base 36: 2.174309 sec. 6500 el base 10: 4.722197 sec; base 16: 6.60522 sec; base 36: 10.552795 sec. Added test for corner cases and sign bit corruption. Replaced macros with inline and hid it inside C file to not pollute global namespace Old bug in #define LG2_LOOKUP: Replaced with inline function and table recalculated for all bases 2 to 36 (was 2 to 64)
2015-07-31erts: fix binary_to_integer boundary caseMikael Pettersson
erlang:binary_to_integer/1 and /2 fail to detect invalid input consisting of a single + or - sign but nothing else. For an input like <<"+">> they return 0, while list_to_integer/1 correctly signals a badarg for "+". Fixed by checking if the input is empty after the initial +/- sign processing. Added a test case which fails without this fix but passes with it. Thanks to "niku" for reporting the issue.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-03-25erts: Fix bug in list_to_integer for very large stringsSverker Eriksson
list_to_integer(lists:duplicate(10000000,$0)). crashed due to overflow when calculating nr heap words.
2014-09-04erts: Correct conversion of MIN_SMALL numeral to fixnumSverker Eriksson
list_to_integer and binary_to_integer returned un-normalized bignum for -134217728 on 32-bit and -576460752303423488 on 64-bit. Thanks to Jesper Louis Andersen, Mikael Pettersson and Anthony Ramine for report, initial patch and optimization suggestion.
2013-09-09Fix incorrect values returned by integer_to_binary/2Juan Jose Comellas
When integer_to_binary/2 receives 0 or a negative number as an argument with a base that is different from 10, it will return incorrect values (<<>> in the case of 0) or it will crash (with negative numbers). This commit fixes these problems and adds tests to cover these cases.
2013-02-14Add float_to_binary and binary_to_floatLukas Larsson
2013-02-14Add new binary conversion bifsLukas Larsson
Added: binary_to_integer/1,2, integer_to_binary/1,2
2013-02-07float_to_list/2 changed rounding and cosmetic cleanupSerge Aleynikov
Changed rouding to round half-way up instead of down. Cosmetic cleanup and error handling of additional edge cases.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-21Text representation of a float formatted using given options.Serge Aleynikov
This BIF solves a problem of float_to_list/1 that doesn't allow specifying the number of digits after the decimal point when formatting floats. float_to_list(Float, Options) -> string() Float = float() Options = [Option] Option = {decimals, Decimals::0..249} | {scientific, Decimals::0..249} | compact Returns a string which corresponds to the text representation of a `Float` formatted using given options. When decimals option is specified the returned value will contain at most `Decimals` number of digits past the decimal point. When `compact` option is provided the trailing zeros at the end of the list are truncated (this option is only meaningful together with the `decimals` option). When `scientific` option is provided, the float will be formatted using scientific notation with `Decimals` digits of precision. If `Options` is `[]` the function behaves like `float_to_list/1`. When using `decimals` option and the number doesn't fit in the static internal buffer of 256 bytes the function throws `badarg`.
2011-03-11Update copyright yearsBjörn-Egil Dahlberg
2011-02-17Rename Suite Callback to Common Test HookLukas Larsson
2011-02-17Fix formatting for emulatorLukas Larsson
2011-02-17Add init_per_suite and end_per_suiteLukas Larsson
2011-02-17Add ts_install_scb to suite/0Lukas Larsson
2011-02-17Update emulator tests to conform with common_test standardLukas Larsson
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP