Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anurag_1812

  • one year ago

#include<stdio.h> int main() { float f1 = 14.375; float f2 = 14.385; if(f1 == 14.375) printf("YES\n"); else printf("NO\n"); if(f2 == 14.385) printf("YES\n"); else printf("NO\n"); return 0; }

  • This Question is Open
  1. anurag_1812
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    what should be the o/p of this code and why? thnks in advance.

  2. hedjm
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi, try to use the debugger to see the actual values in memory see the Attach file (an image from my debugger VC++) You can see that the actual value for f2 is: 14.3850002

    1 Attachment
  3. hedjm
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    try to use: f to compare with the exact precision ok see this code: #include<stdio.h> #include<float.h> using namespace std; int main() { float f1 = 14.375; float f2 = 14.385; if(f1 == 14.375f) printf("YES\n"); else printf("NO\n"); if(f2 == 14.385f) printf("YES\n"); else printf("NO\n"); return 0; }

  4. fitsyu
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    YES YES

  5. classicalyomi
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes Yes

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.