changmind 发表于 2020-4-15 19:36:51

关于浮点数运算

想准确的浮点数运算,是引入decimal,可是为什么我计算的还是有问题?是我代码错误吗?

BngThea 发表于 2020-4-15 20:08:20

Decimal中要写入字符串形式
x=decimal.Decimal('0.1')

zltzlt 发表于 2020-4-15 20:16:15

Decimal() 中要写字符串,不是浮点数

x = decimal.Decimal('0.1')
y = decimal.Decimal('0.2')

changmind 发表于 2020-4-16 13:07:20

BngThea 发表于 2020-4-15 20:08
Decimal中要写入字符串形式
x=decimal.Decimal('0.1')

原来是这样,日常学习get
页: [1]
查看完整版本: 关于浮点数运算