Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Testing expects numerical
NaN
s andInfinity
s, but does not check if normal digits areString
s orNumber
s. It's not specified either.It should be specified ( preferably as
Number
s, though theString
s'-'
and'.'
grate ), and it should be tested.Because the reference solution isn't even arbitrary precision real arithmetic, the answer derived by the reference solution is simply wrong. e.g:
The correct result is
0.25663885990172302292589578160906176584827770888387331907749834099698695209475275668754975679175249426790238934990...
as shown by Wolfram Alpha:http://www.wolframalpha.com/input/?i=1000000000000000+%2F+3896526038118073
Edit: as another demonstration of the incorrect behaviour, I tested some inputs where
a === b
, and the reference solution aren't even giving1.0000...
:Needs tests with large initial dividend and a small divisor. Very large (or small) quotients aren't tested at all.
Since this is a kata about big decimal, the typical stuff should be banned, aka all the ways that can cause
require('bignumber.js')
to work.Also there is no point in identifying
-0
. It's considered practically the same to everything except toObject.is
, and even(-0).toString()
gives0
. It's analogous to saying that allNaN
s are equal, which is absurd, an artifact of IEEE floats standard and not a good practice in any means.There is no point in getting digits below precision of a double, because they aren't even resolvable. Even a change in the tiniest significant bit in the divisor will cause the result to change significantly after the 16th digit (aka
1/Number.MAX_SAFE_INTEGER
).I don't think you really understand the intracacies of arbitrary precision real arithmetic. They simply aren't done this way. To begin with, passing numbers in as floating point values is already a grave mistake. They should be passed in as strings (but then this kata would be a duplicate to https://www.codewars.com/kata/divide-numbers-as-strings).
Random tests section titles has a typo: Things like
-2345658712136251.5 = 7811398559714191 =
should be-2345658712136251.5 / 7811398559714191 =
.