Thread: What is a NaN ?

  1. #1
    Registered User
    Join Date
    Aug 2006

    What is a NaN ?

    float a,b,c,d,k,x,y;
    printf("Enetr the values of a,b,c=>");
    scanf("%f %f %f",&a,&b,&c);
    x= (-b+k)/(2*a);
    y= (-b-k)/(2*a);
    printf("The quadratic equation is x=%f and y=%f",x,y);
    but after compiling the result is look like this .....why ....

    wnter the values of a,b,c=>6 5 4
    sqrt" DOMAIN error
    The quadratic equation is x=+NAN and y=+NAN

    its the program for to find out the result of the qudratic equation

    with regards
    anupam jamatia
    Last edited by Salem; 08-08-2006 at 05:57 AM. Reason: Change title and add code tags - still, indentation is crap

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    That's it. I'm not helping ANYONE from now on if they aren't using CODE TAGS.

    Go read the forum guidelines until you figure out how to use code tags. Do not pass GO, do not collect $200.

    Hope is the first step on the road to disappointment.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    step 1) Use code tags

    step 2) Use a meaningful subject. "Help me" says nothing. Why would you be creating a thread if you didn't need help?

    EDIT: Ohhhhh, quzah beat me.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Mar 2006
    Have you actually tried solving [6x2 + 5x + 4 = 0] manually?

    Other problems:
    int main()
    float x = {expression returning double}
    #include <stdio.h>
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > sqrt" DOMAIN error
    It means don't do square roots on negative numbers. You need to check this before calling sqrt() and print appropriate answers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    NaN means Not a Number.
    Have a nice day.
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning Nan or Inf
    By magda3227 in forum C Programming
    Replies: 4
    Last Post: 07-01-2008, 05:41 PM
  2. nan disappear when printing
    By liats80 in forum C Programming
    Replies: 10
    Last Post: 02-03-2008, 02:17 PM
  3. double, NaN, and super small numbers
    By nbo10 in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 06:50 PM
  4. a question about nan
    By FOOTOO in forum C Programming
    Replies: 14
    Last Post: 04-26-2007, 01:19 PM
  5. Using NaN in c++
    By Hardboy in forum C++ Programming
    Replies: 3
    Last Post: 03-04-2003, 06:44 AM