Numpy 数据精度

34 篇文章 0 订阅

https://docs.scipy.org/doc/numpy-dev/user/basics.types.html

数据类型描述
bool_Boolean (True or False) stored as a byte
int_Default integer type (same as C long normally either int64 or int32)
intcIdentical to C int (normally int32 or int64)
intpInteger used for indexing (same as C ssize_tnormally either int32 or int64)
int8Byte (-128 to 127)
int16Integer (-32768 to 32767)
int32Integer (-2147483648 to 2147483647)
int64Integer (-9223372036854775808 to 9223372036854775807)
uint8Unsigned integer (0 to 255)
uint16Unsigned integer (0 to 65535)
uint32Unsigned integer (0 to 4294967295)
uint64Unsigned integer (0 to 18446744073709551615)
float_Shorthand for float64.
float16Half precision float: sign bit, 5 bits exponent, 10 bits mantissa
float32Single precision float: sign bit, 8 bits exponent, 23 bits mantissa
float64Double precision float: sign bit, 11 bits exponent, 52 bits mantissa
complex_Shorthand for complex128.
complex64Complex number, represented by two 32-bit floats (real and imaginary components)
complex128Complex number, represented by two 64-bit floats (real and imaginary components)

单精度8位阶码,1位符号,剩下23位尾数,算出2的负23次方,得到0.00000011920928955078125
前面0有多少个,就表示能精确到那一位
双精度11位阶码,1位符号,剩下52位尾数,算出2的负52次方,得到0.00000000000000022204460492503130808472633361816
前面0有多少个,就表示能精确到那一位

参考文献
http://bbs.bccn.net/thread-316069-1-1.html
http://blog.csdn.net/qq_34312386/article/details/52454701
http://blog.sina.com.cn/s/blog_814e83d80101bgcf.html
https://zhidao.baidu.com/question/181927800.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Numpy是Python中用于科学计算的一个重要库,它提供了丰富的数据类型来处理不同类型的数据。根据引用所述,Numpy支持的数据类型主要包括以下几种: 1. 整型(integrate):用于表示整数值,可以是有符号或无符号的。不同的整型数据类型根据占用内存的字节数不同,例如int8、int16、int32和int64等。 2. 浮点型(float):用于表示实数值,包括单精度浮点数和双精度浮点数。单精度浮点数使用32位表示,双精度浮点数使用64位表示。 3. 布尔型(bool):用于表示布尔值,即True或False。布尔型数据类型只占用1个字节。 4. 复数型(complex):用于表示复数,包括实部和虚部。复数型数据类型可以是单精度复数或双精度复数,分别使用64位和128位表示。 此外,Numpy还支持自定义类型,可以根据需要定义和使用自己的数据类型。 下面是一个演示Numpy数据类型的例子: ```python import numpy as np # 定义一个整型数组 arr_int = np.array([1, 2, 3], dtype=np.int32) print("整型数组:", arr_int) print("数据类型:", arr_int.dtype) # 定义一个浮点型数组 arr_float = np.array([1.0, 2.0, 3.0], dtype=np.float64) print("浮点型数组:", arr_float) print("数据类型:", arr_float.dtype) # 定义一个布尔型数组 arr_bool = np.array([True, False, True], dtype=np.bool) print("布尔型数组:", arr_bool) print("数据类型:", arr_bool.dtype) # 定义一个复数型数组 arr_complex = np.array([1+2j, 3+4j, 5+6j], dtype=np.complex128) print("复数型数组:", arr_complex) print("数据类型:", arr_complex.dtype) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值