简体   繁体   English

数学中的 1. 或 numpy 是什么? 它应该意味着1.0吗?

[英]What is 1. in Math or numpy? Is it supposed to mean 1.0?


A = np.array([[1, -2, 1], [2, 1, -3], [1, -3, 3]])
b = np.array([6, -3, 10])
x = np.linalg.solve(A, b)
print(x) 
#[ 1. -2.  1.]

What format is this?这是什么格式? This is my first time seeing it.这是我第一次见到它。 how does it translate to normal numbers?它如何转化为正常数字?

The number 1. is a shorter way of writing 1.0 , and indicates that we are not dealing with an integer, but rather a floating point number.数字1.1.0的简写,表示我们处理的不是 integer,而是一个浮点数。 Consider following outputs:考虑以下输出:

>>> import numpy as np
>>> print(np.array([1,-2,1], dtype=float)) 
[ 1. -2.  1.]
>>> print(np.array([1,-2,1], dtype=int))
[ 1 -2  1]
>>> print(np.array([1,-2,1], dtype=np.float32))
[ 1. -2.  1.]
>>> print(np.array([1,-2,1], dtype=np.float16))
[ 1. -2.  1.] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM