From 213a7189537fc7b9cc96f0259e5b7b9e46121927 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 19 Jan 2017 23:37:21 +1100 Subject: tests/float: Add test for assigning to attribute of complex number. --- tests/float/complex1.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/float') diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 027d12583..fed65d5d5 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -51,6 +51,12 @@ print(float('-inf') * (1 + 1j)) # convert bignum to complex on rhs ans = 1j + (1 << 70); print("%.5g %.5g" % (ans.real, ans.imag)) +# can't assign to attributes +try: + (1j).imag = 0 +except AttributeError: + print('AttributeError') + # can't convert rhs to complex try: 1j + [] -- cgit v1.2.3 From 8a39e18f5fc960eb0901b8e219b7026ebe466f3d Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 3 Feb 2017 00:04:13 +1100 Subject: tests/float: Add tests for zero to a negative power. --- tests/float/complex1.py | 5 +++++ tests/float/float1.py | 5 +++++ tests/float/int_divzero.py | 5 +++++ 3 files changed, 15 insertions(+) (limited to 'tests/float') diff --git a/tests/float/complex1.py b/tests/float/complex1.py index fed65d5d5..1031111f3 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -28,6 +28,7 @@ print(1j / 2) print((1j / 2j).real) print(1j / (1 + 2j)) ans = 0j ** 0; print("%.5g %.5g" % (ans.real, ans.imag)) +ans = 0j ** 1; print("%.5g %.5g" % (ans.real, ans.imag)) ans = 0j ** 0j; print("%.5g %.5g" % (ans.real, ans.imag)) ans = 1j ** 2.5; print("%.5g %.5g" % (ans.real, ans.imag)) ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag)) @@ -94,6 +95,10 @@ except ZeroDivisionError: print("ZeroDivisionError") # zero division via power +try: + 0j ** -1 +except ZeroDivisionError: + print("ZeroDivisionError") try: 0j ** 1j except ZeroDivisionError: diff --git a/tests/float/float1.py b/tests/float/float1.py index 0e115032b..93f6f014c 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -75,6 +75,11 @@ try: except ZeroDivisionError: print("ZeroDivisionError") +try: + 0.0 ** -1 +except ZeroDivisionError: + print("ZeroDivisionError") + # unsupported unary ops try: diff --git a/tests/float/int_divzero.py b/tests/float/int_divzero.py index b037dd8c7..b311a1dbc 100644 --- a/tests/float/int_divzero.py +++ b/tests/float/int_divzero.py @@ -2,3 +2,8 @@ try: 1 / 0 except ZeroDivisionError: print("ZeroDivisionError") + +try: + 0 ** -1 +except ZeroDivisionError: + print("ZeroDivisionError") -- cgit v1.2.3 From 325c4473a5b760a2251a6e0e418abf218741fb1f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 Mar 2017 15:46:01 +0100 Subject: tests/float/complex1: Split out intbig test. --- tests/float/complex1.py | 3 --- tests/float/complex1_intbig.py | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 tests/float/complex1_intbig.py (limited to 'tests/float') diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 1031111f3..8c8d285e1 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -49,9 +49,6 @@ print(float('nan') * 1j) print(float('inf') * (1 + 1j)) print(float('-inf') * (1 + 1j)) -# convert bignum to complex on rhs -ans = 1j + (1 << 70); print("%.5g %.5g" % (ans.real, ans.imag)) - # can't assign to attributes try: (1j).imag = 0 diff --git a/tests/float/complex1_intbig.py b/tests/float/complex1_intbig.py new file mode 100644 index 000000000..ed2390bba --- /dev/null +++ b/tests/float/complex1_intbig.py @@ -0,0 +1,4 @@ +# test basic complex number functionality + +# convert bignum to complex on rhs +ans = 1j + (1 << 70); print("%.5g %.5g" % (ans.real, ans.imag)) -- cgit v1.2.3 From 121fb88988fd4b4511476231943e999cf38b2866 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 Mar 2017 16:23:09 +0100 Subject: float/float2int*: Make actually be parsable for MICROPY_LONGINT_IMPL_NONE. The use of large literal numbers is a big no-no when it comes to writing programs which work with different int representations. Also, some checks are pretty adhoc (e.g using struct module to check for 64-bitness). This change bases entire detection on sys.maxsize and integer operarions, and thus more correct, even if longer. Note that this change doesn't mean that any of these tests can pass with anything but MPZ - even despite checking for various int representations, the tests aren't written to be portable among them. --- tests/float/float2int.py | 34 ++++++++++++++++++++++------------ tests/float/float2int_doubleprec.py | 32 ++++++++++++++++++++------------ tests/float/float2int_fp30.py | 32 ++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 36 deletions(-) (limited to 'tests/float') diff --git a/tests/float/float2int.py b/tests/float/float2int.py index da530cee6..3596d2f73 100644 --- a/tests/float/float2int.py +++ b/tests/float/float2int.py @@ -5,21 +5,31 @@ try: except: import struct +import sys + +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + # work out configuration values -is_64bit = struct.calcsize("P") == 8 +is_64bit = maxsize_bits > 32 # 0 = none, 1 = long long, 2 = mpz -try: - dummy = 0x7fffffffffffffff - try: - if (0xffffffffffffffff + 1) > 0: - ll_type = 2 - else: - ll_type = 1 - except: - # in case the sum in the if statement above changes to raising an exception on overflow +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: ll_type = 1 -except: - ll_type = 0 + else: + ll_type = 2 + # basic conversion print(int(14187745.)) diff --git a/tests/float/float2int_doubleprec.py b/tests/float/float2int_doubleprec.py index acdc8c69c..de2137d66 100644 --- a/tests/float/float2int_doubleprec.py +++ b/tests/float/float2int_doubleprec.py @@ -5,21 +5,29 @@ try: except: import struct +import sys +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + # work out configuration values -is_64bit = struct.calcsize("P") == 8 +is_64bit = maxsize_bits > 32 # 0 = none, 1 = long long, 2 = mpz -try: - dummy = 0x7fffffffffffffff - try: - if (0xffffffffffffffff + 1) > 0: - ll_type = 2 - else: - ll_type = 1 - except: - # in case the sum in the if statement above changes to raising an exception on overflow +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: ll_type = 1 -except: - ll_type = 0 + else: + ll_type = 2 # This case occurs with time.time() values if ll_type != 0: diff --git a/tests/float/float2int_fp30.py b/tests/float/float2int_fp30.py index bad9c31e9..fbb94a4cc 100644 --- a/tests/float/float2int_fp30.py +++ b/tests/float/float2int_fp30.py @@ -5,21 +5,29 @@ try: except: import struct +import sys +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + # work out configuration values -is_64bit = struct.calcsize("P") == 8 +is_64bit = maxsize_bits > 32 # 0 = none, 1 = long long, 2 = mpz -try: - dummy = 0x7fffffffffffffff - try: - if (0xffffffffffffffff + 1) > 0: - ll_type = 2 - else: - ll_type = 1 - except: - # in case the sum in the if statement above changes to raising an exception on overflow +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: ll_type = 1 -except: - ll_type = 0 + else: + ll_type = 2 # basic conversion print(int(14187744.)) -- cgit v1.2.3 From 4b03941f5e3f7b6b722303a7cf7aedcd75a4a13f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 Mar 2017 16:30:12 +0100 Subject: tests/float2int*: Suffix with _intbig, don't run on any other int type. I.e. they don't run successfully with MICROPY_LONGINT_IMPL_NONE and MICROPY_LONGINT_IMPL_LONGLONG (the problem is that they generate different output than CPython, TODO to fix that). --- tests/float/float2int.py | 99 ---------------------------- tests/float/float2int_doubleprec.py | 100 ----------------------------- tests/float/float2int_doubleprec_intbig.py | 100 +++++++++++++++++++++++++++++ tests/float/float2int_fp30.py | 97 ---------------------------- tests/float/float2int_fp30_intbig.py | 97 ++++++++++++++++++++++++++++ tests/float/float2int_intbig.py | 99 ++++++++++++++++++++++++++++ 6 files changed, 296 insertions(+), 296 deletions(-) delete mode 100644 tests/float/float2int.py delete mode 100644 tests/float/float2int_doubleprec.py create mode 100644 tests/float/float2int_doubleprec_intbig.py delete mode 100644 tests/float/float2int_fp30.py create mode 100644 tests/float/float2int_fp30_intbig.py create mode 100644 tests/float/float2int_intbig.py (limited to 'tests/float') diff --git a/tests/float/float2int.py b/tests/float/float2int.py deleted file mode 100644 index 3596d2f73..000000000 --- a/tests/float/float2int.py +++ /dev/null @@ -1,99 +0,0 @@ -# check cases converting float to int, relying only on single precision float - -try: - import ustruct as struct -except: - import struct - -import sys - -maxsize_bits = 0 -maxsize = sys.maxsize -while maxsize: - maxsize >>= 1 - maxsize_bits += 1 - -# work out configuration values -is_64bit = maxsize_bits > 32 -# 0 = none, 1 = long long, 2 = mpz -ll_type = None -if is_64bit: - if maxsize_bits < 63: - ll_type = 0 -else: - if maxsize_bits < 31: - ll_type = 0 -if ll_type is None: - one = 1 - if one << 65 < one << 62: - ll_type = 1 - else: - ll_type = 2 - - -# basic conversion -print(int(14187745.)) -print("%d" % 14187745.) -if ll_type == 2: - print(int(2.**100)) - print("%d" % 2.**100) - -testpass = True -p2_rng = ((30,63,127),(62,63,127))[is_64bit][ll_type] -for i in range(0,p2_rng): - bitcnt = len(bin(int(2.**i))) - 3; - if i != bitcnt: - print('fail: 2.**%u was %u bits long' % (i, bitcnt)); - testpass = False -print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) - -# TODO why does 10**12 fail this test for single precision float? -testpass = True -p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11 -for i in range(0,p10_rng): - digcnt = len(str(int(10.**i))) - 1; - if i != digcnt: - print('fail: 10.**%u was %u digits long' % (i, digcnt)); - testpass = False -print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) - -def fp2int_test(num, name, should_fail): - try: - x = int(num) - passed = ~should_fail - except: - passed = should_fail - print('%s: %s' % (name, passed and 'passed' or 'failed')) - -if ll_type != 2: - if ll_type == 0: - if is_64bit: - neg_bad_fp = -1.00000005*2.**62. - pos_bad_fp = 2.**62. - neg_good_fp = -2.**62. - pos_good_fp = 0.99999993*2.**62. - else: - neg_bad_fp = -1.00000005*2.**30. - pos_bad_fp = 2.**30. - neg_good_fp = -2.**30. - pos_good_fp = 0.9999999499*2.**30. - else: - neg_bad_fp = -0.51*2.**64. - pos_bad_fp = 2.**63. - neg_good_fp = -2.**63. - pos_good_fp = 1.9999998*2.**62. - - fp2int_test(neg_bad_fp, 'neg bad', True) - fp2int_test(pos_bad_fp, 'pos bad', True) - fp2int_test(neg_good_fp, 'neg good', False) - fp2int_test(pos_good_fp, 'pos good', False) -else: - fp2int_test(-1.999999879*2.**127., 'large neg', False) - fp2int_test(1.999999879*2.**127., 'large pos', False) - -fp2int_test(float('inf'), 'inf test', True) -fp2int_test(float('nan'), 'NaN test', True) - -# test numbers < 1 (this used to fail; see issue #1044) -fp2int_test(0.0001, 'small num', False) -struct.pack('I', int(1/2)) diff --git a/tests/float/float2int_doubleprec.py b/tests/float/float2int_doubleprec.py deleted file mode 100644 index de2137d66..000000000 --- a/tests/float/float2int_doubleprec.py +++ /dev/null @@ -1,100 +0,0 @@ -# check cases converting float to int, requiring double precision float - -try: - import ustruct as struct -except: - import struct - -import sys -maxsize_bits = 0 -maxsize = sys.maxsize -while maxsize: - maxsize >>= 1 - maxsize_bits += 1 - -# work out configuration values -is_64bit = maxsize_bits > 32 -# 0 = none, 1 = long long, 2 = mpz -ll_type = None -if is_64bit: - if maxsize_bits < 63: - ll_type = 0 -else: - if maxsize_bits < 31: - ll_type = 0 -if ll_type is None: - one = 1 - if one << 65 < one << 62: - ll_type = 1 - else: - ll_type = 2 - -# This case occurs with time.time() values -if ll_type != 0: - print(int(1418774543.)) - print("%d" % 1418774543.) - if ll_type == 3: - print(int(2.**100)) - print("%d" % 2.**100) -else: - print(int(1073741823.)) - print("%d" % 1073741823.) - -testpass = True -p2_rng = ((30,63,1024),(62,63,1024))[is_64bit][ll_type] -for i in range(0,p2_rng): - bitcnt = len(bin(int(2.**i))) - 3; - if i != bitcnt: - print('fail: 2**%u was %u bits long' % (i, bitcnt)); - testpass = False -print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) - -testpass = True -p10_rng = ((9,18,23),(18,18,23))[is_64bit][ll_type] -for i in range(0,p10_rng): - digcnt = len(str(int(10.**i))) - 1; - if i != digcnt: - print('fail: 10**%u was %u digits long' % (i, digcnt)); - testpass = False -print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) - -def fp2int_test(num, name, should_fail): - try: - x = int(num) - passed = ~should_fail - except: - passed = should_fail - print('%s: %s' % (name, passed and 'passed' or 'failed')) - -if ll_type != 2: - if ll_type == 0: - if is_64bit: - neg_bad_fp = -1.00000005*2.**62. - pos_bad_fp = 2.**62. - neg_good_fp = -2.**62. - pos_good_fp = 0.99999993*2.**62. - else: - neg_bad_fp = -1.00000005*2.**30. - pos_bad_fp = 2.**30. - neg_good_fp = -2.**30. - pos_good_fp = 0.9999999499*2.**30. - else: - neg_bad_fp = -0.51*2.**64. - pos_bad_fp = 2.**63. - neg_good_fp = -2.**63. - pos_good_fp = 1.9999998*2.**62. - - fp2int_test(neg_bad_fp, 'neg bad', True) - fp2int_test(pos_bad_fp, 'pos bad', True) - fp2int_test(neg_good_fp, 'neg good', False) - fp2int_test(pos_good_fp, 'pos good', False) -else: - fp2int_test(-1.9999999999999981*2.**1023., 'large neg', False) - fp2int_test(1.9999999999999981*2.**1023., 'large pos', False) - -fp2int_test(float('inf'), 'inf test', True) -fp2int_test(float('nan'), 'NaN test', True) - -# test numbers < 1 (this used to fail; see issue #1044) -fp2int_test(0.0001, 'small num', False) -struct.pack('I', int(1/2)) diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py new file mode 100644 index 000000000..de2137d66 --- /dev/null +++ b/tests/float/float2int_doubleprec_intbig.py @@ -0,0 +1,100 @@ +# check cases converting float to int, requiring double precision float + +try: + import ustruct as struct +except: + import struct + +import sys +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + +# work out configuration values +is_64bit = maxsize_bits > 32 +# 0 = none, 1 = long long, 2 = mpz +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: + ll_type = 1 + else: + ll_type = 2 + +# This case occurs with time.time() values +if ll_type != 0: + print(int(1418774543.)) + print("%d" % 1418774543.) + if ll_type == 3: + print(int(2.**100)) + print("%d" % 2.**100) +else: + print(int(1073741823.)) + print("%d" % 1073741823.) + +testpass = True +p2_rng = ((30,63,1024),(62,63,1024))[is_64bit][ll_type] +for i in range(0,p2_rng): + bitcnt = len(bin(int(2.**i))) - 3; + if i != bitcnt: + print('fail: 2**%u was %u bits long' % (i, bitcnt)); + testpass = False +print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) + +testpass = True +p10_rng = ((9,18,23),(18,18,23))[is_64bit][ll_type] +for i in range(0,p10_rng): + digcnt = len(str(int(10.**i))) - 1; + if i != digcnt: + print('fail: 10**%u was %u digits long' % (i, digcnt)); + testpass = False +print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) + +def fp2int_test(num, name, should_fail): + try: + x = int(num) + passed = ~should_fail + except: + passed = should_fail + print('%s: %s' % (name, passed and 'passed' or 'failed')) + +if ll_type != 2: + if ll_type == 0: + if is_64bit: + neg_bad_fp = -1.00000005*2.**62. + pos_bad_fp = 2.**62. + neg_good_fp = -2.**62. + pos_good_fp = 0.99999993*2.**62. + else: + neg_bad_fp = -1.00000005*2.**30. + pos_bad_fp = 2.**30. + neg_good_fp = -2.**30. + pos_good_fp = 0.9999999499*2.**30. + else: + neg_bad_fp = -0.51*2.**64. + pos_bad_fp = 2.**63. + neg_good_fp = -2.**63. + pos_good_fp = 1.9999998*2.**62. + + fp2int_test(neg_bad_fp, 'neg bad', True) + fp2int_test(pos_bad_fp, 'pos bad', True) + fp2int_test(neg_good_fp, 'neg good', False) + fp2int_test(pos_good_fp, 'pos good', False) +else: + fp2int_test(-1.9999999999999981*2.**1023., 'large neg', False) + fp2int_test(1.9999999999999981*2.**1023., 'large pos', False) + +fp2int_test(float('inf'), 'inf test', True) +fp2int_test(float('nan'), 'NaN test', True) + +# test numbers < 1 (this used to fail; see issue #1044) +fp2int_test(0.0001, 'small num', False) +struct.pack('I', int(1/2)) diff --git a/tests/float/float2int_fp30.py b/tests/float/float2int_fp30.py deleted file mode 100644 index fbb94a4cc..000000000 --- a/tests/float/float2int_fp30.py +++ /dev/null @@ -1,97 +0,0 @@ -# check cases converting float to int, relying only on single precision float - -try: - import ustruct as struct -except: - import struct - -import sys -maxsize_bits = 0 -maxsize = sys.maxsize -while maxsize: - maxsize >>= 1 - maxsize_bits += 1 - -# work out configuration values -is_64bit = maxsize_bits > 32 -# 0 = none, 1 = long long, 2 = mpz -ll_type = None -if is_64bit: - if maxsize_bits < 63: - ll_type = 0 -else: - if maxsize_bits < 31: - ll_type = 0 -if ll_type is None: - one = 1 - if one << 65 < one << 62: - ll_type = 1 - else: - ll_type = 2 - -# basic conversion -print(int(14187744.)) -print("%d" % 14187744.) -if ll_type == 2: - print(int(2.**100)) - print("%d" % 2.**100) - -testpass = True -p2_rng = ((30,63,127),(62,63,127))[is_64bit][ll_type] -for i in range(0,p2_rng): - bitcnt = len(bin(int(2.**i))) - 3; - if i != bitcnt: - print('fail: 2.**%u was %u bits long' % (i, bitcnt)); - testpass = False -print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) - -# TODO why does 10**12 fail this test for single precision float? -testpass = True -p10_rng = 9 -for i in range(0,p10_rng): - digcnt = len(str(int(10.**i))) - 1; - if i != digcnt: - print('fail: 10.**%u was %u digits long' % (i, digcnt)); - testpass = False -print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) - -def fp2int_test(num, name, should_fail): - try: - x = int(num) - passed = ~should_fail - except: - passed = should_fail - print('%s: %s' % (name, passed and 'passed' or 'failed')) - -if ll_type != 2: - if ll_type == 0: - if is_64bit: - neg_bad_fp = -1.00000005*2.**62. - pos_bad_fp = 2.**62. - neg_good_fp = -2.**62. - pos_good_fp = 0.99999993*2.**62. - else: - neg_bad_fp = -1.00000005*2.**30. - pos_bad_fp = 2.**30. - neg_good_fp = -2.**30. - pos_good_fp = 0.9999999499*2.**30. - else: - neg_bad_fp = -0.51*2.**64. - pos_bad_fp = 2.**63. - neg_good_fp = -2.**63. - pos_good_fp = 1.9999998*2.**62. - - fp2int_test(neg_bad_fp, 'neg bad', True) - fp2int_test(pos_bad_fp, 'pos bad', True) - fp2int_test(neg_good_fp, 'neg good', False) - fp2int_test(pos_good_fp, 'pos good', False) -else: - fp2int_test(-1.999999879*2.**126., 'large neg', False) - fp2int_test(1.999999879*2.**126., 'large pos', False) - -fp2int_test(float('inf'), 'inf test', True) -fp2int_test(float('nan'), 'NaN test', True) - -# test numbers < 1 (this used to fail; see issue #1044) -fp2int_test(0.0001, 'small num', False) -struct.pack('I', int(1/2)) diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py new file mode 100644 index 000000000..fbb94a4cc --- /dev/null +++ b/tests/float/float2int_fp30_intbig.py @@ -0,0 +1,97 @@ +# check cases converting float to int, relying only on single precision float + +try: + import ustruct as struct +except: + import struct + +import sys +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + +# work out configuration values +is_64bit = maxsize_bits > 32 +# 0 = none, 1 = long long, 2 = mpz +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: + ll_type = 1 + else: + ll_type = 2 + +# basic conversion +print(int(14187744.)) +print("%d" % 14187744.) +if ll_type == 2: + print(int(2.**100)) + print("%d" % 2.**100) + +testpass = True +p2_rng = ((30,63,127),(62,63,127))[is_64bit][ll_type] +for i in range(0,p2_rng): + bitcnt = len(bin(int(2.**i))) - 3; + if i != bitcnt: + print('fail: 2.**%u was %u bits long' % (i, bitcnt)); + testpass = False +print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) + +# TODO why does 10**12 fail this test for single precision float? +testpass = True +p10_rng = 9 +for i in range(0,p10_rng): + digcnt = len(str(int(10.**i))) - 1; + if i != digcnt: + print('fail: 10.**%u was %u digits long' % (i, digcnt)); + testpass = False +print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) + +def fp2int_test(num, name, should_fail): + try: + x = int(num) + passed = ~should_fail + except: + passed = should_fail + print('%s: %s' % (name, passed and 'passed' or 'failed')) + +if ll_type != 2: + if ll_type == 0: + if is_64bit: + neg_bad_fp = -1.00000005*2.**62. + pos_bad_fp = 2.**62. + neg_good_fp = -2.**62. + pos_good_fp = 0.99999993*2.**62. + else: + neg_bad_fp = -1.00000005*2.**30. + pos_bad_fp = 2.**30. + neg_good_fp = -2.**30. + pos_good_fp = 0.9999999499*2.**30. + else: + neg_bad_fp = -0.51*2.**64. + pos_bad_fp = 2.**63. + neg_good_fp = -2.**63. + pos_good_fp = 1.9999998*2.**62. + + fp2int_test(neg_bad_fp, 'neg bad', True) + fp2int_test(pos_bad_fp, 'pos bad', True) + fp2int_test(neg_good_fp, 'neg good', False) + fp2int_test(pos_good_fp, 'pos good', False) +else: + fp2int_test(-1.999999879*2.**126., 'large neg', False) + fp2int_test(1.999999879*2.**126., 'large pos', False) + +fp2int_test(float('inf'), 'inf test', True) +fp2int_test(float('nan'), 'NaN test', True) + +# test numbers < 1 (this used to fail; see issue #1044) +fp2int_test(0.0001, 'small num', False) +struct.pack('I', int(1/2)) diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py new file mode 100644 index 000000000..3596d2f73 --- /dev/null +++ b/tests/float/float2int_intbig.py @@ -0,0 +1,99 @@ +# check cases converting float to int, relying only on single precision float + +try: + import ustruct as struct +except: + import struct + +import sys + +maxsize_bits = 0 +maxsize = sys.maxsize +while maxsize: + maxsize >>= 1 + maxsize_bits += 1 + +# work out configuration values +is_64bit = maxsize_bits > 32 +# 0 = none, 1 = long long, 2 = mpz +ll_type = None +if is_64bit: + if maxsize_bits < 63: + ll_type = 0 +else: + if maxsize_bits < 31: + ll_type = 0 +if ll_type is None: + one = 1 + if one << 65 < one << 62: + ll_type = 1 + else: + ll_type = 2 + + +# basic conversion +print(int(14187745.)) +print("%d" % 14187745.) +if ll_type == 2: + print(int(2.**100)) + print("%d" % 2.**100) + +testpass = True +p2_rng = ((30,63,127),(62,63,127))[is_64bit][ll_type] +for i in range(0,p2_rng): + bitcnt = len(bin(int(2.**i))) - 3; + if i != bitcnt: + print('fail: 2.**%u was %u bits long' % (i, bitcnt)); + testpass = False +print("power of 2 test: %s" % (testpass and 'passed' or 'failed')) + +# TODO why does 10**12 fail this test for single precision float? +testpass = True +p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11 +for i in range(0,p10_rng): + digcnt = len(str(int(10.**i))) - 1; + if i != digcnt: + print('fail: 10.**%u was %u digits long' % (i, digcnt)); + testpass = False +print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) + +def fp2int_test(num, name, should_fail): + try: + x = int(num) + passed = ~should_fail + except: + passed = should_fail + print('%s: %s' % (name, passed and 'passed' or 'failed')) + +if ll_type != 2: + if ll_type == 0: + if is_64bit: + neg_bad_fp = -1.00000005*2.**62. + pos_bad_fp = 2.**62. + neg_good_fp = -2.**62. + pos_good_fp = 0.99999993*2.**62. + else: + neg_bad_fp = -1.00000005*2.**30. + pos_bad_fp = 2.**30. + neg_good_fp = -2.**30. + pos_good_fp = 0.9999999499*2.**30. + else: + neg_bad_fp = -0.51*2.**64. + pos_bad_fp = 2.**63. + neg_good_fp = -2.**63. + pos_good_fp = 1.9999998*2.**62. + + fp2int_test(neg_bad_fp, 'neg bad', True) + fp2int_test(pos_bad_fp, 'pos bad', True) + fp2int_test(neg_good_fp, 'neg good', False) + fp2int_test(pos_good_fp, 'pos good', False) +else: + fp2int_test(-1.999999879*2.**127., 'large neg', False) + fp2int_test(1.999999879*2.**127., 'large pos', False) + +fp2int_test(float('inf'), 'inf test', True) +fp2int_test(float('nan'), 'NaN test', True) + +# test numbers < 1 (this used to fail; see issue #1044) +fp2int_test(0.0001, 'small num', False) +struct.pack('I', int(1/2)) -- cgit v1.2.3 From 88ffe0d5cc697aea61cee950e6388ef9419df7f4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 7 Mar 2017 00:13:36 +0100 Subject: tests/string_format_modulo2: Split off intbig test. --- tests/float/string_format_modulo2.py | 4 ++-- tests/float/string_format_modulo2_intbig.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/float/string_format_modulo2_intbig.py (limited to 'tests/float') diff --git a/tests/float/string_format_modulo2.py b/tests/float/string_format_modulo2.py index d35f2a2c0..f6b1ae537 100644 --- a/tests/float/string_format_modulo2.py +++ b/tests/float/string_format_modulo2.py @@ -18,7 +18,7 @@ def test(num, num_str): # check pure zero test(0.0, '0.0') -# check most powers of 10, making sure to include exponents with 3 digits -for e in range(-101, 102): +# check some powers of 10, making sure to include exponents with 3 digits +for e in range(-8, 8): num = pow(10, e) test(num, '1e%d' % e) diff --git a/tests/float/string_format_modulo2_intbig.py b/tests/float/string_format_modulo2_intbig.py new file mode 100644 index 000000000..9992ba65d --- /dev/null +++ b/tests/float/string_format_modulo2_intbig.py @@ -0,0 +1,21 @@ +# test formatting floats with large precision, that it doesn't overflow the buffer + +def test(num, num_str): + if num == float('inf') or num == 0.0 and num_str != '0.0': + # skip numbers that overflow or underflow the FP precision + return + for kind in ('e', 'f', 'g'): + # check precision either side of the size of the buffer (32 bytes) + for prec in range(23, 36, 2): + fmt = '%.' + '%d' % prec + kind + s = fmt % num + check = abs(float(s) - num) + if num > 1: + check /= num + if check > 1e-6: + print('FAIL', num_str, fmt, s, len(s), check) + +# check most powers of 10, making sure to include exponents with 3 digits +for e in range(-101, 102): + num = pow(10, e) + test(num, '1e%d' % e) -- cgit v1.2.3 From a0cbc108ba9dbdd4cc223486561f3e6a347e2d0a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 9 Mar 2017 00:11:05 +0100 Subject: tests/float: Make various tests skippable. --- tests/float/array_construct.py | 7 ++++++- tests/float/builtin_float_minmax.py | 7 +++++++ tests/float/float_array.py | 7 ++++++- tests/float/float_struct.py | 12 ++++++++---- 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'tests/float') diff --git a/tests/float/array_construct.py b/tests/float/array_construct.py index a25cc72c8..7e01fd476 100644 --- a/tests/float/array_construct.py +++ b/tests/float/array_construct.py @@ -1,6 +1,11 @@ # test construction of array from array with float type -from array import array +try: + from array import array +except ImportError: + import sys + print("SKIP") + sys.exit() print(array('f', array('h', [1, 2]))) print(array('d', array('f', [1, 2]))) diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py index ce45a768a..42cfa6382 100644 --- a/tests/float/builtin_float_minmax.py +++ b/tests/float/builtin_float_minmax.py @@ -1,4 +1,11 @@ # test builtin min and max functions with float args +try: + min + max +except: + import sys + print("SKIP") + sys.exit() print(min(0,1.0)) print(min(1.0,0)) diff --git a/tests/float/float_array.py b/tests/float/float_array.py index 033877db3..8bc963444 100644 --- a/tests/float/float_array.py +++ b/tests/float/float_array.py @@ -1,4 +1,9 @@ -from array import array +try: + from array import array +except ImportError: + import sys + print("SKIP") + sys.exit() def test(a): print(a) diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index e55890a2c..a36ccce38 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -1,9 +1,13 @@ # test struct package with floats - try: - import ustruct as struct -except: - import struct + try: + import ustruct as struct + except: + import struct +except ImportError: + import sys + print("SKIP") + sys.exit() i = 1. + 1/2 # TODO: it looks like '=' format modifier is not yet supported -- cgit v1.2.3 From bacb52aa2dbf8dcb1e96aace28a85108ef0a8245 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 23 Mar 2017 23:54:10 +1100 Subject: tests/float: Add tests for math funcs that return ints. One should test bigint, inf and nan to make sure all cases are covered. --- tests/float/math_fun_int.py | 15 +++++++++++++++ tests/float/math_fun_intbig.py | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/float/math_fun_int.py create mode 100644 tests/float/math_fun_intbig.py (limited to 'tests/float') diff --git a/tests/float/math_fun_int.py b/tests/float/math_fun_int.py new file mode 100644 index 000000000..ee54f0995 --- /dev/null +++ b/tests/float/math_fun_int.py @@ -0,0 +1,15 @@ +# test the math functions that return ints + +try: + import math +except ImportError: + print("SKIP") + import sys + sys.exit() + +for fun in (math.ceil, math.floor, math.trunc): + for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')): + try: + print(fun(x)) + except (ValueError, OverflowError) as e: + print(type(e)) diff --git a/tests/float/math_fun_intbig.py b/tests/float/math_fun_intbig.py new file mode 100644 index 000000000..962c10daa --- /dev/null +++ b/tests/float/math_fun_intbig.py @@ -0,0 +1,12 @@ +# test the math functions that return ints, with very large results + +try: + import math +except ImportError: + print("SKIP") + import sys + sys.exit() + +for fun in (math.ceil, math.floor, math.trunc): + for x in (-1e25, 1e25): + print('%.3g' % fun(x)) -- cgit v1.2.3 From bfb48c1620256b883804c5998f91b8a897b4b6ff Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 24 Mar 2017 10:56:02 +1100 Subject: tests/float: Add tests for round() of inf, nan and large number. --- tests/float/builtin_float_round.py | 7 +++++++ tests/float/builtin_float_round_intbig.py | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 tests/float/builtin_float_round_intbig.py (limited to 'tests/float') diff --git a/tests/float/builtin_float_round.py b/tests/float/builtin_float_round.py index de72514db..63cb39aa3 100644 --- a/tests/float/builtin_float_round.py +++ b/tests/float/builtin_float_round.py @@ -15,3 +15,10 @@ for i in range(11): # test second arg for i in range(-1, 3): print(round(1.47, i)) + +# test inf and nan +for val in (float('inf'), float('nan')): + try: + round(val) + except (ValueError, OverflowError) as e: + print(type(e)) diff --git a/tests/float/builtin_float_round_intbig.py b/tests/float/builtin_float_round_intbig.py new file mode 100644 index 000000000..2083e3ea3 --- /dev/null +++ b/tests/float/builtin_float_round_intbig.py @@ -0,0 +1,4 @@ +# test round() with floats that return large integers + +for x in (-1e25, 1e25): + print('%.3g' % round(x)) -- cgit v1.2.3 From 28876d3902c84774018f81204f81b6cc01784855 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 3 Apr 2017 00:17:43 +0300 Subject: tests/float/byte*_construct: Skip on missing array module. --- tests/float/bytearray_construct.py | 7 ++++++- tests/float/bytes_construct.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/float') diff --git a/tests/float/bytearray_construct.py b/tests/float/bytearray_construct.py index f72926635..db946a99d 100644 --- a/tests/float/bytearray_construct.py +++ b/tests/float/bytearray_construct.py @@ -1,5 +1,10 @@ # test construction of bytearray from array with float type -from array import array +try: + from array import array +except ImportError: + import sys + print("SKIP") + sys.exit() print(bytearray(array('f', [1, 2.3]))) diff --git a/tests/float/bytes_construct.py b/tests/float/bytes_construct.py index 0a57e08a2..8664d7296 100644 --- a/tests/float/bytes_construct.py +++ b/tests/float/bytes_construct.py @@ -1,5 +1,10 @@ # test construction of bytearray from array with float type -from array import array +try: + from array import array +except ImportError: + import sys + print("SKIP") + sys.exit() print(bytes(array('f', [1, 2.3]))) -- cgit v1.2.3 From 677fb3101525bc655d9fd548b8c2cecfc8deefd2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 4 Apr 2017 12:14:34 +1000 Subject: tests/float: Add tests for hashing float and complex numbers. --- tests/float/builtin_float_hash.py | 22 ++++++++++++++++++++++ tests/float/complex1.py | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 tests/float/builtin_float_hash.py (limited to 'tests/float') diff --git a/tests/float/builtin_float_hash.py b/tests/float/builtin_float_hash.py new file mode 100644 index 000000000..ba6b63907 --- /dev/null +++ b/tests/float/builtin_float_hash.py @@ -0,0 +1,22 @@ +# test builtin hash function with float args + +# these should hash to an integer with a specific value +for val in ( + '0.0', + '1.0', + '2.0', + '-12.0', + '12345.0', + ): + print(val, hash(float(val))) + +# just check that these values are hashable +for val in ( + '0.1', + '-0.1', + '10.3', + 'inf', + '-inf', + 'nan', + ): + print(val, type(hash(float(val)))) diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 8c8d285e1..a6038de04 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -41,6 +41,10 @@ print(1j == 1j) print(abs(1j)) print("%.5g" % abs(1j + 2)) +# builtin hash +print(hash(1 + 0j)) +print(type(hash(1j))) + # float on lhs should delegate to complex print(1.2 + 3j) -- cgit v1.2.3 From fde54350a8d740308d12c2ea4c65fa5bea4f186a Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 8 Jun 2017 14:00:57 +1000 Subject: tests/float: Convert "sys.exit()" to "raise SystemExit". The latter is shorter and simpler because it doesn't require importing the sys module. --- tests/float/array_construct.py | 3 +-- tests/float/builtin_float_minmax.py | 3 +-- tests/float/bytearray_construct.py | 3 +-- tests/float/bytes_construct.py | 3 +-- tests/float/cmath_fun.py | 3 +-- tests/float/cmath_fun_special.py | 3 +-- tests/float/float_array.py | 3 +-- tests/float/float_struct.py | 3 +-- tests/float/math_fun.py | 3 +-- tests/float/math_fun_bool.py | 3 +-- tests/float/math_fun_int.py | 3 +-- tests/float/math_fun_intbig.py | 3 +-- tests/float/math_fun_special.py | 3 +-- 13 files changed, 13 insertions(+), 26 deletions(-) (limited to 'tests/float') diff --git a/tests/float/array_construct.py b/tests/float/array_construct.py index 7e01fd476..938675835 100644 --- a/tests/float/array_construct.py +++ b/tests/float/array_construct.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(array('f', array('h', [1, 2]))) print(array('d', array('f', [1, 2]))) diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py index 42cfa6382..20ad3ddf4 100644 --- a/tests/float/builtin_float_minmax.py +++ b/tests/float/builtin_float_minmax.py @@ -3,9 +3,8 @@ try: min max except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(min(0,1.0)) print(min(1.0,0)) diff --git a/tests/float/bytearray_construct.py b/tests/float/bytearray_construct.py index db946a99d..e960d624e 100644 --- a/tests/float/bytearray_construct.py +++ b/tests/float/bytearray_construct.py @@ -3,8 +3,7 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(bytearray(array('f', [1, 2.3]))) diff --git a/tests/float/bytes_construct.py b/tests/float/bytes_construct.py index 8664d7296..0e4482e43 100644 --- a/tests/float/bytes_construct.py +++ b/tests/float/bytes_construct.py @@ -3,8 +3,7 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(bytes(array('f', [1, 2.3]))) diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py index 3ebcf5918..ae5921c30 100644 --- a/tests/float/cmath_fun.py +++ b/tests/float/cmath_fun.py @@ -4,8 +4,7 @@ try: from cmath import * except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit # make sure these constants exist in cmath print("%.5g" % e) diff --git a/tests/float/cmath_fun_special.py b/tests/float/cmath_fun_special.py index 422964dd7..471fda8c0 100644 --- a/tests/float/cmath_fun_special.py +++ b/tests/float/cmath_fun_special.py @@ -5,8 +5,7 @@ try: log10 except (ImportError, NameError): print("SKIP") - import sys - sys.exit() + raise SystemExit test_values_non_zero = [] base_values = (0.0, 0.5, 1.2345, 10.) diff --git a/tests/float/float_array.py b/tests/float/float_array.py index 8bc963444..8c8edcff7 100644 --- a/tests/float/float_array.py +++ b/tests/float/float_array.py @@ -1,9 +1,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit def test(a): print(a) diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index a36ccce38..c4c186b89 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -5,9 +5,8 @@ try: except: import struct except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit i = 1. + 1/2 # TODO: it looks like '=' format modifier is not yet supported diff --git a/tests/float/math_fun.py b/tests/float/math_fun.py index d9f179587..80d20bd8a 100644 --- a/tests/float/math_fun.py +++ b/tests/float/math_fun.py @@ -4,8 +4,7 @@ try: from math import * except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.] test_values_small = [-10., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 10.] # so we don't overflow 32-bit precision diff --git a/tests/float/math_fun_bool.py b/tests/float/math_fun_bool.py index 57232857a..30ab14a52 100644 --- a/tests/float/math_fun_bool.py +++ b/tests/float/math_fun_bool.py @@ -4,8 +4,7 @@ try: from math import isfinite, isnan, isinf except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'), -float('NaN'), -float('Inf')] diff --git a/tests/float/math_fun_int.py b/tests/float/math_fun_int.py index ee54f0995..5cadbb1e5 100644 --- a/tests/float/math_fun_int.py +++ b/tests/float/math_fun_int.py @@ -4,8 +4,7 @@ try: import math except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit for fun in (math.ceil, math.floor, math.trunc): for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')): diff --git a/tests/float/math_fun_intbig.py b/tests/float/math_fun_intbig.py index 962c10daa..697ca7a6d 100644 --- a/tests/float/math_fun_intbig.py +++ b/tests/float/math_fun_intbig.py @@ -4,8 +4,7 @@ try: import math except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit for fun in (math.ceil, math.floor, math.trunc): for x in (-1e25, 1e25): diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py index 32249b423..c3665a7cd 100644 --- a/tests/float/math_fun_special.py +++ b/tests/float/math_fun_special.py @@ -5,8 +5,7 @@ try: erf except (ImportError, NameError): print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [-8., -2.5, -1, -0.5, 0.0, 0.5, 2.5, 8.,] pos_test_values = [0.001, 0.1, 0.5, 1.0, 1.5, 10.,] -- cgit v1.2.3 From e09420075017423f17073347eacad45ef4d3b860 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 8 Jun 2017 17:23:22 +0300 Subject: tests/float/builtin_float_minmax: PEP8 fixes. --- tests/float/builtin_float_minmax.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests/float') diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py index 20ad3ddf4..266ed133d 100644 --- a/tests/float/builtin_float_minmax.py +++ b/tests/float/builtin_float_minmax.py @@ -6,27 +6,27 @@ except: print("SKIP") raise SystemExit -print(min(0,1.0)) -print(min(1.0,0)) -print(min(0,-1.0)) -print(min(-1.0,0)) +print(min(0, 1.0)) +print(min(1.0, 0)) +print(min(0, -1.0)) +print(min(-1.0, 0)) -print(max(0,1.0)) -print(max(1.0,0)) -print(max(0,-1.0)) -print(max(-1.0,0)) +print(max(0, 1.0)) +print(max(1.0, 0)) +print(max(0, -1.0)) +print(max(-1.0, 0)) -print(min(1.5,-1.5)) -print(min(-1.5,1.5)) +print(min(1.5, -1.5)) +print(min(-1.5, 1.5)) -print(max(1.5,-1.5)) -print(max(-1.5,1.5)) +print(max(1.5, -1.5)) +print(max(-1.5, 1.5)) -print(min([1,2.9,4,0,-1,2])) -print(max([1,2.9,4,0,-1,2])) +print(min([1, 2.9, 4, 0, -1, 2])) +print(max([1, 2.9, 4, 0, -1, 2])) -print(min([1,2.9,4,6.5,-1,2])) -print(max([1,2.9,4,6.5,-1,2])) -print(min([1,2.9,4,-6.5,-1,2])) -print(max([1,2.9,4,-6.5,-1,2])) +print(min([1, 2.9, 4, 6.5, -1, 2])) +print(max([1, 2.9, 4, 6.5, -1, 2])) +print(min([1, 2.9, 4, -6.5, -1, 2])) +print(max([1, 2.9, 4, -6.5, -1, 2])) -- cgit v1.2.3