0
I was trying to add a few decimal points initialized as variables and the output of the number was extremely long: 

var a = .1 ;
var b = .2 ;
var c = a + b ;
document.write(c) ;

The c variable returns a number of 0.30000000000000004, Ive searched high and wide and can't find an explanation why some floats return perfectly rounded answers and some dont.

Patrick
  • 77
  • 1
  • 2
  • 9
  • Does this help? http://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate – andybeli Apr 17 '15 at 23:13
  • hey, it's pretty close ain't it? – dandavis Apr 17 '15 at 23:15
  • Yea it is super close but Im reading the article that andybeli posted to try to get a better understanding of why some floats are drawn out more than others. Maybe if I create another variable and multiply .2 and .1 by 10 and divide it by 1 that might work. – Patrick Apr 17 '15 at 23:20

0 Answers0