Search code examples
exceptiondb2overflowarithmetic-expressions

DB2 EXP() command returning arithmetic overflow


Hi I am using the EXP() command in DB2 on a column of type float as so

select distinct 1 - power(0.9144,exp(beta - 0.1)) from mytable

where this all works fine until I introduce the exp() around (beta - 0.1). beta is a float and ranges between 3018.878989897931 and 12289.951602012534.

the error I am getting is

Arithmetic overflow or other arithmetic exception occurred.. SQLCODE=-802,SQLSTATE=22003,DRIVER=3.64.106

what could be the issue here?


Solution

  • Obviously, the issue here is your exceeding the maximum range representable by a 64-bit floating point number format, which is about +1.79769E+308.

    If you do need to work with larger numbers, consider performing calculations in DECFLOAT(34) instead (if your DB2 version supports this data type).