diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-07 12:10:47 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-07 12:10:47 +0000 |
commit | ad2307c92c15f0aa90dbd0741fd2538719d0b5e1 (patch) | |
tree | 3082ec3627306b5f674364900f2ede2bceb40a8e /tests/float/float2int_doubleprec.py | |
parent | d8bfd77ad5df1417094f125efa9b97a8d35c03cb (diff) |
py: Temporary fix for conversion of float to int when fits in small int.
Addresses issue #1044 (see also #1040). Could do with a better fix.
Diffstat (limited to 'tests/float/float2int_doubleprec.py')
-rw-r--r-- | tests/float/float2int_doubleprec.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/float/float2int_doubleprec.py b/tests/float/float2int_doubleprec.py new file mode 100644 index 000000000..c6fe3783e --- /dev/null +++ b/tests/float/float2int_doubleprec.py @@ -0,0 +1,21 @@ +# check cases converting float to int, requiring double precision float + +# This case occurs with time.time() values +print(int(1418774543.)) +print("%d" % 1418774543.) + +testpass = True +for i in range(0,1024): + 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 +for i in range(0,23): + 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')) |