int a=7
int b=10
float answer = (float)a/b;
answer=0.699999988 ( I expect 0.7 ??)
See Question&Answers more detail:osint a=7
int b=10
float answer = (float)a/b;
answer=0.699999988 ( I expect 0.7 ??)
See Question&Answers more detail:osThe short version is: Floating points are not accurate, it's only a finite set of bits, and a finite set of bits cannot be used to represent an infinite set of numbers.
The longer version is here: What Every Computer Scientist Should Know About Floating-Point Arithmetic
See also: