The Programmer's Challenge of the Day

in programming •  7 years ago 

IMG-20170823-WA0004.jpg

Write The Answer in Comments section below


For more such PROGRAMMING CHALLENGES

Follow @yashhanda

DQmb2XLRnqy5netJri1pMXwqxB22MxujE4XakYcHeVUpQqx.gif


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Answer is 'YES' and it happens like this because 'a' is in float but 0.7 is by default double so the binary representation of both vary and causes this result to occur.
To get correct result you need to use a < 0.7f : )

It's true.
It's damn true.

Thanks for the explanation.

  ·  7 years ago (edited)

B. No?

Sorry my friend. It's Yes.
Answer is 'YES' and it happens like this because 'a' is in float but 0.7 is by default double so the binary representation of both vary and causes this result to occur.
To get correct result you need to use a < 0.7f : )

For more deeper understanding refer: https://stackoverflow.com/questions/6883306/floating-point-comparison-a-0-7

And remember to upvote and follow please.