LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2004, 09:51 PM   #1
mkh
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Rep: Reputation: 0
problem of "NaN" in redhat 7.3, with gcc-2.96 while running c_code


I need some help from this forum. Initially it is posted in the "newbie-linux" forum, where it is suggested to move it to this forum.

I am compiling a program in c language in my linux machine-redhat linux 7.3, gcc version 2.96. The program involves some arrays of "double precision floating points", defined and evaluated under different routines.
While running the program I get some elemnts of the arrays to be "nan". (These elements are computed in one operation, stored in the array and used later for further computation.) The problem is peculiar in the sense that when I try to use the stored value of the element and try to learn its value just before using, it shows "nan". But when I check, if really it was an illegal computation by using "printf" immediately sfter coputation/storing the element, it shows a value to the element and stores the same value, allows its use in later operations; and the problem of "nan" vanishes. i.e., using "printf" after computation of the element removes the problem of having a "nan". However that is not desirable.
When I searched in the net I came across some reference to similar instances but could not get a clear indication to the "follow up action" (probably due to my own limitation, as I am quite new to linux os). I hope some suggestion from this forum will help me coming out of my problem.


(The original code was written by a third party. I am trying to modify it to suit my requirement and there, I get the problem. I am enclosing the "problematic part" of the program.

Removed on 12/1/04 at 1.05 p.m.)

To be honest I am not having any clue about the problem.
Thanking in advance,


Last edited by mkh; 01-12-2004 at 01:33 AM.
 
Old 01-11-2004, 04:00 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
That's just way too much code for me to wrap my brain around without a full working program Maybe you could post a link to a tarball of it so I can play around.

In my experience, having a printf() or some other function call fix an odd problem usually means that you're reading from a corrupted piece of memory. Maybe you're not reserving enough space and without the printf() call that memory is being used somewhere else or something?
 
Old 01-11-2004, 01:38 PM   #3
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,
mkh, can you compile this part of the program?
i took a look but i was not able even to compile... a lot error concerning undeclared variable...
we need the header of the program... declarations...
like itsme86 said it is complicated to help with such a code... we can not figure out where is the mistake without compiling too much code..
Regards
 
Old 01-12-2004, 01:17 AM   #4
mkh
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks Slakie1000 and itsme86 for your response. Perhaps I could not present my problem well enough. Also, before putting in to the post I did not compile the part_progarm separately, but picked the problematic part. Sorry for the inconvenience caused.
However, in the mean-time a google_session helped me where observation was that "removing any mismatch in declaration of the routine in the main" may help. Following the suggestion I was benefited (initially the routines were not defined explicitly in the main) and at present it is working.
Thanks again to all concerned.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User "list" running process "python" TroelsSmit Linux - Newbie 2 02-22-2005 04:55 AM
error running "make" and "arkollonrc"... Toro Linux - Software 1 04-19-2004 12:24 AM
problem with "NaN" in redhat 7.3, with gcc-2.96 mkh Programming 4 01-12-2004 01:05 PM
How can I recover my RedHat if it BOOTs to a "Kernel Panic" error and stop running? yuzuohong Linux - General 5 12-05-2002 10:39 PM
Is solution for control "NaN" and "Inf" in C/C++ gmitra Programming 2 09-19-2002 08:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration