定点算法 [英] Fixed-point arithmetic

查看:167
本文介绍了定点算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在Python中执行定点运算的库吗? 还是有人有示例代码?

Does anyone know of a library to do fixed point arithmetic in Python? Or, does anyone has sample code?

推荐答案

如果您有兴趣进行定点运算,则Python标准库提供了

If you are interested in doing fixed point arithmetic, the Python Standard Library has a decimal module that can do it.

实际上,它具有比内置功能更灵活的浮点功能.灵活的意思是:

Actually, it has a more flexible floating point ability than the built-in too. By flexible I mean that it:

  • 具有用于各种特殊情况的信号"(可以将其设置为在信号处理方面做各种事情)

  • Has "signals" for various exceptional conditions (these can be set to do a variety of things on signaling)

具有正面和负面影响 无穷大,以及NaN(不是 号码)

Has positive and negative infinities, as well as NaN (not a number)

可以区分正数 负0

允许您设置不同的舍入 方案.

Allows you to set different rounding schemes.

允许您设置自己的最小值和 最大值.

Allows you to set your own min and max values.

总而言之,对于数百万家庭使用而言,这很方便.

All in all, it is handy for a million household uses.

这篇关于定点算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆