Like Tree1Likes
  • 1 Post By Salem

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

This is a discussion on Why does my program get these warnings?Could you help me? within the C Programming forums, part of the General Programming Boards category; im getting this warnings but i've not solved it yet, when i compile the program, in the 400 line , ...

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

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,747
    > 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.
    rac1 likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    74
    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, 11: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, 05:40 AM
  4. Warnings that mess up the program...
    By Dark Nemesis in forum Windows Programming
    Replies: 9
    Last Post: 08-31-2003, 07:58 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21