883
Numpy Data Types
The various data types supported by numpy are as follows
Numpy data type | Storage Size | Description |
np.bool_ | 1 byte | can hold boolean values, like (True or False) or (0 or 1) |
np.byte | 1 byte | can hold values from 0 to 255 |
np.ubyte | 1 byte | can hold values from -128 to 127 |
np.short | 2 bytes | can hold values from -32,768 to 32,767 |
np.ushort | 2 bytes | can hold values from 0 to 65,535 |
np.uintc | 2 or 4 bytes | can hold values from 0 to 65,535 or 0 to 4,294,967,295 |
np.int_ | 8 bytes | can hold values from -9223372036854775808 to 9223372036854775807 |
np.uint | 8 bytes | 0 to 18446744073709551615 |
np.longlong | 8 bytes | can hold values from -9223372036854775808 to 9223372036854775807 |
np.ulonglong | 8 bytes | 0 to 18446744073709551615 |
np.half / np.float16 | allows half float precision with Format: sign bit, 5 bits exponent, 10 bits mantissa |
|
np.single | 4 bytes | allows single float precision Format: sign bit, 8 bits exponent, 23 bits mantissa |
np.double | 8 bytes | allows double float precision Format: sign bit, 11 bits exponent, 52 bits mantissa. |
np.longdouble | 8 bytes | extension of float |
np.csingle | 8 bytes | can hold complex with real and imaginary parts up to single-precision float |
np.cdouble | 16 bytes | can hold complex with real and imaginary parts up to double-precision float |
np.clongdouble | 16 bytes | extension of float for complex number |
np.int8 | 1 byte | can hold values from -128 to 127 |
np.int16 | 2 bytes | can hold values from -32,768 to 32,767 |
np.int32 | 4 bytes | can hold values from -2,147,483,648 to 2,147,483,647 |
np.int64 | 8 bytes | can hold values from -9223372036854775808 to 9223372036854775807 |
np.uint8 | 1 byte | can hold values from 0 to 255 |
np.uint16 | 2 bytes | can hold values from 0 to 65,535 |
np.uint32 | 4 bytes | can hold values from 0 to 4,294,967,295 |
np.uint64 | 8 bytes | can hold values from 0 to 18446744073709551615 |
np.intp | 4 bytes | a signed integer used for indexing |
np.uintp | 4 bytes | an unsigned integer used for holding a pointer |
np.float32 | 4 bytes | single float precision |
np.float64 | 8 bytes | double float precision |
np.complex64 | 8 bytes | single float precision in complex numbers |
np.complex128 | 16 bytes | double float precision in complex numbers |