I am doing scientific calculations with both very small and large numbers, so obviously if I'm using python the decimal.Decimal()
representation is key. The problem is the tedium. Having to type Decimal()
around every relevant operation is cumbersome.
Is there a way to set the default numeric representation as Decimal
somewhere, anywhere?
答案 0 :(得分:1)
No, although you can alias the module to a shorter name:
In [1]: from decimal import Decimal as d
In [2]: d(10)
Out[2]: Decimal('10')
答案 1 :(得分:1)
不可能。浮动的使用在整个地方都是硬编码的,许多数字例程实际上不能对其他任何操作,特别是用C语言编写的东西。