QB64 Phoenix Edition
Limitation of function EXP() - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2)
+--- Thread: Limitation of function EXP() (/showthread.php?tid=1495)

Pages: 1 2


RE: Limitation of function EXP() - RhoSigma - 02-23-2023

I've updated the EXP wiki page, but there's a limit for type _FLOAT too (709,....).

However, you don't necessarily need to DIM AS _FLOAT, you can also specify literal numbers as _FLOAT by appending the respective type suffix (##) to the number, e.g. EXP(567.89##)


RE: Limitation of function EXP() - Jack - 02-23-2023

(02-22-2023, 06:27 PM)SMcNeill Wrote:
Code: (Select All)
// EXP
double func_exp_single(double value) {
    if (value <= 88.02969) {
        return exp(value);
    }
    error(6);
    return 0;
}
long double func_exp_float(long double value) {
    if (value <= 709.782712893) {
        return exp(value);
    }
    error(6);
    return 0;
}

@SMcNeill

in this statement: if (value <= 709.782712893)
what if value is -11356 for example?
I think that it needs to be something like the following
Code: (Select All)
long double func_exp_float(long double value) {
    if (fabsl(value) <= 11355) {
        return exp(value);
    }
    error(6);
    return 0;
}



RE: Limitation of function EXP() - jcm - 02-23-2023

(02-23-2023, 02:57 PM)Jack Wrote:
(02-22-2023, 06:27 PM)SMcNeill Wrote:
Code: (Select All)
// EXP
double func_exp_single(double value) {
    if (value <= 88.02969) {
        return exp(value);
    }
    error(6);
    return 0;
}
long double func_exp_float(long double value) {
    if (value <= 709.782712893) {
        return exp(value);
    }
    error(6);
    return 0;
}

@SMcNeill

in this statement: if (value <= 709.782712893)
what if value is -11356 for example?
I think that it needs to be something like the following
Code: (Select All)
long double func_exp_float(long double value) {
    if (fabsl(value) <= 11355) {
        return exp(value);
    }
    error(6);
    return 0;
}
The limitation is with the definition of the maximum double 1.7976E+308

the maximum number = ln(1.7976E308)=709.78177061


RE: Limitation of function EXP() - RhoSigma - 02-23-2023

Once again updated/clarified the EXP wiki page. Got a bit confused by the C++ function names respectively passed parameter types.

In fact @Jack was right, EXP is not really supporting _FLOAT precision, although you may pass such a value, it's still limited to 709.something, as DOUBLE runs through the same C++ function and so the limit of the smaller type must be taken.