NumPy also provides other float types, known from other programming languages as double-precision and single-precision numbers, namely, float64 and float32:
a = pi # returns 3.141592653589793
a1 = float64(a) # returns 3.141592653589793
a2 = float32(a) # returns 3.1415927
a - a1 # returns 0.0
a - a2 # returns -8.7422780126189537e-08
The second last line demonstrates that a and a1 do not differ in accuracy. A difference in accuracy exists between a and its single-precision counterpart, a2.
The NumPy function finfo can be used to display information on these floating-point types:
f32 = finfo(float32)
f32.precision # 6 (decimal digits)
f64 = finfo(float64)
f64.precision # 15 (decimal digits)
f = finfo(float)
f.precision # 15 (decimal digits)
f64.max # 1.7976931348623157e+308 (largest number)
f32.max # 3.4028235e+38 (largest number)
help(finfo) # Check for more options