Thread: Why does my program get these warnings?Could you help me?

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    72

    Why does my program get these warnings?Could you help me?

    im getting this warnings but i've not solved it yet, when i compile the program, in the 400 line , these 3 lines are gives warning, and it makes me unhappy.I want perfect.
    Some parts of my program

    Code:
    #include <stdio.h>
    #include <math.h>
    ..
     float delta,r1,r2,b,a,c,ii1,ii2=0;
    ..
        if (delta>0)
        {
    w ->    r1=(b-sqrt(delta))/(2*a);
    w ->    r2=(b+sqrt(delta))/(2*a);
         printf(" r1=%f\n r2=%f\n\n\n",r1,r2);
        }
        .....
        else
        {
             r1=b/(2*a);
    w ->   ii1=(sqrt(-delta))/(2*a);
        // r2=-b/(2*a)
        //ii2=sqrt(-delta)/(2*a));     
         printf(" r1=%f+i%f\n r2=%f-i%f\n\n\n",r1,ii1,r1,ii1);
        }
    .....
    return 0;
    here is the warnings
    warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
    there are three same warnings


    thanks for reading my topic.Help me plz
    Last edited by rac1; 11-26-2011 at 11:36 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > float delta,r1,r2,b,a,c,ii1,ii2=0;
    So change this to

    double delta,r1,r2,b,a,c,ii1,ii2=0;

    floats are a historic relic, from when machines had very limited amounts of memory (say 64KB - Yes, you read it right - Kilobytes) and no floating point hardware.
    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.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    72
    Finished.obj - 0 error(s), 0 warning(s)
    Thank you Salem )))))))) im very happy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program crashing despite no errors and warnings
    By yohanevindra in forum C Programming
    Replies: 10
    Last Post: 09-07-2010, 10:40 PM
  2. How DO I Get Rid Of Warnings?
    By bumfluff in forum Windows Programming
    Replies: 3
    Last Post: 11-24-2006, 06:34 PM
  3. GCC Warnings
    By 00Sven in forum C Programming
    Replies: 12
    Last Post: 05-03-2006, 04:40 AM
  4. Warnings that mess up the program...
    By Dark Nemesis in forum Windows Programming
    Replies: 9
    Last Post: 08-31-2003, 06:58 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM