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
|
Limitation of function EXP() - BSpinoza - 02-22-2023 Why is in QB64 a limitation of the function EXP ? "EXP(numericExpression) ... The numericExpression must be less than or equal to 88.02969 or an "overflow" error will occur." In C a similar limitation is much higher. (I need it to use the Planck's law to calculate the spectral density of the electromagnetic radiation at low temperatures.) With my C program the Planck's law can be applied at a temperature of 1K, in QB64 not lower than 102 K! RE: Limitation of function EXP() - mnrvovrfc - 02-22-2023 To cure yourself, you could import the function from C++: https://qb64phoenix.com/qb64wiki/index.php/C_Libraries#C_Functions_and_Subs Discover which one you want and prototype it surrounding it with "DECLARE LIBRARY... END DECLARE" block. "EXP()" in QB64(PE) isn't going to be changed because it was part of the behavior of QuickBASIC and QBasic. RE: Limitation of function EXP() - Jack - 02-22-2023 @BSpinoza I think that the Exp function in QB64 supports _Float, but remember that print only supports double you may be able to do your calculation using _Float RE: Limitation of function EXP() - Sprezzo - 02-22-2023 (02-22-2023, 11:26 AM)BSpinoza Wrote: Why is in QB64 a limitation of the function EXP ? Good question. Say, can you do the whole calculation in log space rather than using the exp function? We do this a lot in statistical mechanics. Spill the math here if you want, I'll get there with you if its possible. RE: Limitation of function EXP() - Kernelpanic - 02-22-2023 (02-22-2023, 11:26 AM)BSpinoza Wrote: Why is in QB64 a limitation of the function EXP ? I don't get an error message. Or what am I doing wrong? Code: (Select All) Option _Explicit RE: Limitation of function EXP() - SMcNeill - 02-22-2023 Looks to me like QB64 can handle values larger than 88... Code: (Select All) // EXP There's our EXP functions. If you pass it a single, it needs a value of 88 or less. Pass it a double/float, and it works with a value < 709. RE: Limitation of function EXP() - Kernelpanic - 02-22-2023 Yes, an integer causes an error. RE: Limitation of function EXP() - Jack - 02-22-2023 (02-22-2023, 12:22 PM)Jack Wrote: @BSpinoza I was wrong, QB64 exp function treats _Float as double, however you can use the C function expl Code: (Select All) Declare CustomType Library forgot that the print statement does not support _Float, (it does in my modified version) nevertheless, if the end result is within range of double you can use expl RE: Limitation of function EXP() - BSpinoza - 02-23-2023 It seems to be a problem of the number type! This is working: Code: (Select All) DIM I AS _FLOAT If you remove the DIM statement, it stops at 88. Thanks to all for your answers! RE: Limitation of function EXP() - Jack - 02-23-2023 without the dim statement it defaults to single, you don't need _Float only double as the exp function maximum precision is double |