我如何防止/检测使用EXP()的Postgresql计算中的下溢 [英] How can I prevent/detect an underflow in a Postgresql calculation that uses EXP()

查看:159
本文介绍了我如何防止/检测使用EXP()的Postgresql计算中的下溢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用EXP(x)函数的查询中,我收到的值超出范围:pgsql下溢错误。 x的什么值触发此?如何防止或检测到它?

解决方案

函数exp称为指数函数,其反函数是自然对数,或以e为底的对数。数字e通常也被定义为自然对数的底数。换句话说,exp(x)和e ^ x是相同的函数。但是,由于e是一个超越数,因此是不合理的,因此无法准确给出其值。



e的数值舍去为10位小数是2.71828 1828



因此,函数exp(x)在技术上对x的所有值均有效,但实际上可以限制它们。例如,如果将它们限制为+/- 700,则应覆盖范围

  exp(700)= 1.01423205的所有情况×10 ^ 304 
exp(-700)= 9.85967654×10 ^ -305

更多取决于您的应用


I am receiving a value out of range: underflow error from pgsql, in a query that uses the EXP(x) function. What values of x trigger this? How do I prevent or detect it?

解决方案

The function exp is called the exponential function, and its inverse is the natural logarithm, or logarithm to base e. The number e is also commonly defined as the base of the natural logarithm

In other words, exp(x) and e^x are the same function. However, since e is a transcendental number, and therefore irrational, its value cannot be given exactly.

The Numerical value of e truncated to 10 decimal places is 2.71828 1828

So, the function exp(x) is technically valid for all values of x, but practically speaking, you can limit them. For example, if you limit them to +/- 700 you should cover all cases covering the range

exp(700) = 1.01423205 × 10^304
exp(-700) = 9.85967654 × 10^-305

More than that depends on your application

这篇关于我如何防止/检测使用EXP()的Postgresql计算中的下溢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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