replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Floating Point RUNTIME error in WIN32 - NOT in .NET
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Floating Point RUNTIME error in WIN32 - NOT in .NET

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Lolly



Joined: 10 Dec 2010
Posts: 2

PostPosted: Mon Dec 13, 2010 7:00 pm    Post subject: Floating Point RUNTIME error in WIN32 - NOT in .NET Reply with quote

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
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2621
Location: Sydney

PostPosted: Tue Dec 14, 2010 1:20 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2415
Location: Yateley, Hants, UK

PostPosted: Tue Dec 14, 2010 4:59 pm    Post subject: Reply with quote

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 real*4, and that real*8 is often too precise. Real*6 seems to me a suitable compromise for routine work. Real*10 is for the sort of work you seem to be doing.

Best regards

Eddie
Back to top
View user's profile Send private message
Lolly



Joined: 10 Dec 2010
Posts: 2

PostPosted: Tue Dec 14, 2010 7:15 pm    Post subject: Reply with quote

Thank you very much for these suggestions and further insight. I will try your suggestions and definitly educate myself further.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group