I have some sort of rounding issue when rounding floats.
x = np.array([[1.234793487329877,2.37432987432],[1.348732847,8437.328737874]])
np.round(x,2)
array([[ 1.23000000e+00, 2.37000000e+00],
[ 1.35000000e+00, 8.43733000e+03]])
Is there a way to display these numbers without the zero extensions?
几乎不需要舍入浮点数(除非您想对它们进行存储,否则您的代码就可以正常工作),如果您只想以较低的精度打印它们,请使用以下命令:
print(np.array_str(x, precision=2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.