Then use strings. Floating-point is inherently imprecise due to the limitations of the machine and gains or losses from rounding. It's unreasonable to expect the internal representation of a value to be exactly what the user typed for input, especially given that printf() does its own rounding when converting that value back to a string. In this specific case you can normalize the input and output by forcing a precision to the input:
But that doesn't help if the input changes to use 3 characters past the radix, you'd see the same problem in reverse.
haha.. as if i didn't know, that double is an extension of float. :P
i executed the program with double and in all possible cases. i got same ans but I don't know why it happens.. But, as far as answer's concern, we get the same value printed.
with due respect sir waltP,
I'm not giving any wrong information. I never said that using double will solve the problem. I said that it gives the same value. and as i mentioned before, I don't know why it happens
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...