It's not better, but it's what I had to do to get my R solution to work. Sorry maybe not clear, this is a tip for solutions rather than improving the kata.
actual = 0.599999999999...
truncated to 6 decimals = 0.599999
expected = 0.600000
0.599999 != 0.6 => test fails even though it should reasonably succeed
The only correct thing to do is to use approximate equality, about which i have already raised an issue just below.
R version fixed ;-)
It's not better, but it's what I had to do to get my R solution to work. Sorry maybe not clear, this is a tip for solutions rather than improving the kata.
how is truncating better than rounding ?
The only correct thing to do is to use approximate equality, about which i have already raised an issue just below.
For rounding issues with R, you don't want to round, you want to throw away everything after the 6th decimal.