What is the difference between the built in float
and numpy.float32
?
Example
a = 58682.7578125 print type(a) print a print type(numpy.float32(a)) print numpy.float32(a)
Output:
<type 'float'> 58682.7578125 <type 'numpy.float32'> 58682.8
I've found here that numpy.float32
is:
float32 Single precision float: sign bit, 8 bits exponent, 23 bits mantissa
didn't find what the built in float
format is.
float is one of the available numeric data types in Go used to store decimal numbers. float32 is a version of float that stores decimal values composed of 32 bits of data.
float32. Single precision float: sign bit, 8 bits exponent, 23 bits mantissa.
float32 and np. float64 are numpy specific 32 and 64-bit float types. Thus, when you do isinstance(2.0, np. float) , it is equivalent to isinstance(2.0, float) as 2.0 is a plain python built-in float type... and not the numpy type.
float32 is a 32 bit number - float64 uses 64 bits. That means that float64's take up twice as much memory - and doing operations on them may be a lot slower in some machine architectures. However, float64's can represent numbers much more accurately than 32 bit floats. They also allow much larger numbers to be stored.
Python's standard float
type is a C double
: http://docs.python.org/2/library/stdtypes.html#typesnumeric
NumPy's standard numpy.float
is the same, and is also the same as numpy.float64
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With