Lichen

tests/numbers.py

1027:dd0745ab8b8a
5 months ago Paul Boddie Reordered GCC arguments to prevent linking failures. Someone decided to change the GCC invocation or linking semantics at some point, meaning that libraries specified "too early" in the argument list no longer provide the symbols required by the program objects, whereas specifying them at the end of the argument list allows those symbols to be found and obtained.
     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 ** 29    14 print i                                 # 536870912    15 print hex(i)                            # 0x20000000    16 print oct(i)                            # 04000000000    17     18 j = -2 ** 29    19 print j                                 # -536870912    20 print hex(j)                            # -0x20000000    21 print oct(j)                            # -04000000000    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                                # 536870911    43 print i & ~j                            # 0    44 print i - 1 & ~j                        # 536870911    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