- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am running a program with several computations in a loop. I am getting NaN after a lot many computations. To get clean data free of NaN i made the program stop at first appearance of NaN. I got a breakpoint and what i see is an overflow. Earlier, when i had not induced any such breakpoint, as i went through the data file obtained, i saw NaN values among many normal data. Secondly, despite appearance of NaN the computation went on with number data appearing between NaN values. From this pattern should i assume that i should assign these variables to real(16) rather than real(8)?
please tell me the way out.
Shah
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Real(16) will make things really slow. The NaN are usually caused by division by zero, You need to look improvements to the algorithms being used to trap/prevent this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NaN could be produced by infinity (overflow) times 0, as well as 0/0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank u much Andrew.
its about the algorithm itself. i thought whether the bytes for the numbers just are not enough.
Shah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NaN and Infinity specifically make it possible for a program to continue. With these special numbers any arithmetic operation has a result.
Of course, NaNs are usually an indication that something is not working as expected and your mentioning overflows probably means that your calculation is unstable. Rather than using real numbers with a larger range (REAL(16) would do that) you should analyse why the numbers are getting so big. As we do not know anything about your algorithm we cannot say much about the possible causes.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page