Hi
I don't understand why expected result for 8955.63 is '{"£50":179,"£5":1,"50p":1,"10 p":1,"2p":1}' instead of {"£50":179,"£5":1,"50p":1,"10p":1,"2p":1,"1p":1}
Floating point math is notoriously dodgy in most programming environments, and JavaScript is no different. For example, 0.1 + 0.2 == 0.30000000000000004. You'll have to work around it to solve this kata.
Nice work on the kata, Fumble. To make things a little more interesting (and harder toe cheat), you could randomize the order of the tests and even add randomly-generated ones.
Fair enough - I think I'd searched before submitting this, but evidently not well enough :)
Somewhat duplicate of:
So what's the next step for this kata to come out of beta?
Good catch! JavaScript's floating point arithmetic tripped up my dynamic tests.
Fixed it, should work now.
Hi
I don't understand why expected result for 8955.63 is '{"£50":179,"£5":1,"50p":1,"10 p":1,"2p":1}' instead of {"£50":179,"£5":1,"50p":1,"10p":1,"2p":1,"1p":1}
amount : 8955.63
Expected: {"£50":179,"£5":1,"50p":1,"10p":1,"2p":1}, instead got: {"£50":179,"£5":1,"50p":1,"10p":1,"2p":1,"1p":1}
Good, practical and interesting kata, nice job! I'm gonna have fun cracking this one!
Don't worry; they're never elegant... looks okay to me. ;P
Thanks, wthit56. I've randomised the tests, though I'm not sure if it's elegant!
I started writing an explanation - but this is better: http://floating-point-gui.de/
Floating point math is notoriously dodgy in most programming environments, and JavaScript is no different. For example,
0.1 + 0.2 == 0.30000000000000004
. You'll have to work around it to solve this kata.Any ideas as to why this happens? http://cl.ly/XHpC
I know it's nothing to do with your kata, I just thought I'd see if anyone else is getting it.
Nice work on the kata, Fumble. To make things a little more interesting (and harder toe cheat), you could randomize the order of the tests and even add randomly-generated ones.
This is what you get when you analyse the problem properly before starting out. Kudos!