Erlang会有数学函数的Bignum吗? [英] Will Erlang have Bignums for math functions?

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

问题描述

为什么Erlang不包括数学函数的任意精度?我最近不得不使用数学:pow(2,4333),它会抛出一个错误。为什么Erlang不使用像GMP这样的图书馆?是否有计划将其纳入标准图书馆? (Haskell使用它,[罢工]甚至Java有bignum [罢工])。



谢谢。



更新:
要添加更多的透视图,我明白可以使用NIF来完成。我正在解决黑客中的问题,其中输入使用较大的数字。 pow / 2可以很容易地写在Erlang中,但是对于较大的计算,它会很慢。

Java为 pow 返回双倍,所以它不适用于 Math.pow(2,1024),它赋予 Infinity

解决方案

Erlang具有整数的符号,但使用64位IEEE标准浮点数。所以,尽管你可以通过默认的方式计算 factorial(10000)整数,数学库使用浮点,所以 math:pow(2,4333)不起作用。


Why does Erlang not include arbitrary precision for math functions? I recently had to use math:pow(2,4333), and it throws an error. Why does Erlang not use libraries like GMP? Are there any plans to include it in the standard library? (Haskell uses it, [strike]even Java has bignums[strike]).

Thanks.

Update: To add more perspective, I understand that it can be done using NIFs. I was solving problems from hackerrank in which the input uses larger numbers. pow/2 can be easily written in Erlang and it worked, but for larger computations, it would be slow.
Java returns double for pow so it does not work for Math.pow(2, 1024) which gives Infinity.

解决方案

Erlang has bignums for integers but uses 64-bit IEEE standard floating point numbers. So while you can happily compute factorial(10000) with integers by default the math library uses floating point so math:pow(2, 4333) does not work.

这篇关于Erlang会有数学函数的Bignum吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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