Elixir:(ArithmeticError)算术表达式中的错误参数 [英] Elixir: (ArithmeticError) bad argument in arithmetic expression

查看:145
本文介绍了Elixir:(ArithmeticError)算术表达式中的错误参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的计算:

Enum.reduce(1..5, 0, &:math.pow/2)

但是我得到这个错误:

** (ArithmeticError) bad argument in arithmetic expression
    (stdlib) :math.pow(5, 262144.0)
    (elixir) lib/enum.ex:1478: anonymous fn/3 in Enum.reduce/3
    (elixir) lib/range.ex:80: Enumerable.Range.reduce/5
    (elixir) lib/enum.ex:1477: Enum.reduce/3

Elixir的算术计算是否有限制?

Is there a limitation in Elixir for arithmetic calculations?

推荐答案

您正在尝试计算5^262144-erlang的数目如此之多.这样的数字甚至不能用浮点数表示-最大浮点约为1.7e308

You're trying to calculate 5^262144 - it's such a huge number erlang bails out. Such number can't even be represented by floating point numbers - the maximal float is about 1.7e308

这篇关于Elixir:(ArithmeticError)算术表达式中的错误参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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