float division help

Hi guys ..
float division eats numbers !
when I use the float division , it doesn't give the accurate result , it give me increase or decrease result , here is my code
1
2
3
  float fl;
  fl=2587;
  cout<<fl/10<<endl;

and it give me 258.6999999999999
It gives me 258.7. What is your actual question? You say you want the 258.6999999999999 output or that it is currently outputting that? Because for me it is not.
Last edited on
my currently output is 258.6999999999999
not in case of printing it , but when use it in other parts of code .
when I use the float division , it doesn't give the accurate result

That is quite normal with floating point numbers. Floating point numbers are approximations, they are not exact. Perhaps you should read this:

http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Topic archived. No new replies allowed.