Lichen

tests/numbers.py

638:ba53413ad5de
2017-02-28 Paul Boddie Remove temporary names used by negation operands.
     1 # -*- coding: ISO-8859-1 -*-     2      3 import sys     4      5 print "# sys.maxint:",     6 print sys.maxint     7 print "# sys.minint:",     8 print sys.minint     9     10 print "# sys.maxint + sys.minint:",    11 print sys.maxint + sys.minint    12     13 i = 2 ** 30    14 print i                                 # 1073741824    15 print hex(i)                            # 0x40000000    16 print oct(i)                            # 010000000000    17     18 j = -2 ** 30    19 print j                                 # -1073741824    20 print hex(j)                            # -0x40000000    21 print oct(j)                            # -010000000000    22     23 print i + j                             # 0    24     25 try:    26     print i - j    27 except OverflowError:    28     print "i - j: overflow occurred"    29     30 print i / i                             # 1    31 print i / j                             # -1    32 print j / j                             # 1    33 print j / i                             # -1    34     35 try:    36     print i * j    37 except OverflowError:    38     print "i * j: overflow occurred"    39     40 print i - i                             # 0    41 print j - j                             # 0    42 print ~j                                # 1073741823    43 print i & ~j                            # 0    44 print i - 1 & ~j                        # 1073741823    45     46 print hex(31)                           # 0x1f    47 print oct(31)                           # 037    48     49 print "# hash(sys.maxint):",    50 print hash(sys.maxint)    51     52 print "# hash((sys.maxint, 0)):",    53 print hash((sys.maxint, 0))    54     55 print "# hash((sys.maxint - 1, 0)):",    56 print hash((sys.maxint - 1, 0))    57     58 # Test combining numbers with strings.    59     60 s = "Number is " + str(123)    61 s2 = "??? -> " + str(123)    62 print s.__class__    63 print s2.__class__    64 print s    65 print s2    66     67 sys.stdout.encoding = "UTF-8"    68 print s2