Silverfrost Forums

Welcome to our forums

Floating Point RUNTIME error in WIN32 - NOT in .NET

13 Dec 2010 6:00 #7242

Hi,

I am getting a floating point RUNTIME error while running a program on WIN32 platform. I do not get this error on .NET and program runs fine on .NET.

I know I am generating very small numbers and I suspect that the numbers < 10E-38 may be causing the blowup. It appears that .NET can handle as small as 10E-48.

Could the limitation of 32 bit on WIN32 platform be the problem here? Is there a way for me to fix this problem in WIN32 without limiting the size of my generated numbers?

Thanks for any solutions here.

Lolly

14 Dec 2010 12:20 #7243

Try using REAL*8 and see if that solves the problem. Or compile with /dreal, if you have declared variables using 'REAL', or implicit declarations. There might be a different error handling for real underflow, but I do not know for certain.

14 Dec 2010 3:59 #7246

You are implicitly assuming that .NET is exhibiting the correct behaviour.

FTN95.chm notes (under .NET programs / .NET programming / Arithmetic overflow/underflow) that 'Floating point underflow, which (depending on the algorithm) may or may not represent a true error, can optionally be trapped.' (in .NET. It is always trapped in Win32.) I suggest that if your code does not set it up to be trapped, it probably isn't! Hence, the Win32 version is probably giving you a better handle on the problem.

Single precision underflow does happen at about 10-38, and if you are dealing with numbers that close to zero, you really ought to go for 64-bit reals, or even better, 80-bit reals (which are Win32 only). John Campbell's suggestions are the first steps in tracking your problem down. 64-bit reals will get you down to more like 10-308, and 80-bit reals down to about 10^-4932 (see in FTN95.chm the section kind parameters for intrinsic types / real kinds).

I always found that one has to be VERY careful with real4, and that real8 is often too precise. Real6 seems to me a suitable compromise for routine work. Real10 is for the sort of work you seem to be doing.

Best regards

Eddie

14 Dec 2010 6:15 #7247

Thank you very much for these suggestions and further insight. I will try your suggestions and definitly educate myself further.

Please login to reply.