summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/float2int_doubleprec.py
blob: c6fe3783e665115ed23c2f93fe4678a896d84325 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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'))