#!/usr/bin/python3
# ===============================================================
# size of integers and floats in Python
#
# Python supports regular and short integers. Short integers
# are limited by hardware. (Usually 32-bit or 64-bit.)
# Regular integers are limited by memory.
# ---------------------------------------------------------------
# Short Integers FYI:
#
# a. maximum signed 64 bit integer:
# -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
# −(2^63) to (2^63 − 1)
# b. maximum unsighed 64 bit integer:
# 0 to 18,446,744,073,709,551,615 (2^64 - 1)
# c. maximum signed 32 bit integer:
# -2,147,483,648 to 2,147,483,647
# -(2^31) to (2^31 – 1)
# c. maximum unsigned 32 bit integer:
# 0 to 4,294,967,296 (2^31 – 1)
# ===============================================================
# ---------------------------------------------------------------
# What is the maximum size of short integers supported by the
# hardware Python running on?
#
# The sys.maxsize > 2**32 expression returns True if the Python
# interpreter is runing with 64-bit integers and False if it
# is running with 32-bit integers.
# ---------------------------------------------------------------
import re
import sys
print()
print('integers')
print()
if sys.maxsize > 2**32:
print('using 64 bit integers')
else:
print('using 32 bit integers')
# ---------------------------------------------------------------
# What about floats?
# ---------------------------------------------------------------
import re
print()
print('floats')
print()
info = str(sys.float_info)
##print(info)
# ---- remove leading and trailing "junk"
info = re.sub('^.*\(', '', info)
info = re.sub('\)$', '', info)
# ---- remove leading space before printing
for x in info.split(','):
print(re.sub('^ ', '', x))