Python float to Decimal conversion

后端 未结 9 1973
渐次进展
渐次进展 2020-12-05 03:50

Python Decimal doesn\'t support being constructed from float; it expects that you have to convert float to a string first.

This is very inconvenient since standard

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 04:31

    The "right" way to do this was documented in 1990 by Steele and White's and Clinger's PLDI 1990 papers.

    You might also look at this SO discussion about Python Decimal, including my suggestion to try using something like frap to rationalize a float.

提交回复
热议问题