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.
This comment is hidden because it contains spoiler information about the solution
added to all languages
Changed the note to "Zero (0) is not checked for any specific sign. Negative zeros make no mathematical sense."
Thanks for the feedback. XD
This Kata is meant to be super easy. I am sorry that the note I originally wrote for the C# version of this Kata doesn't make sense in your fancy JavaScript world.
Do you want me to just remove the NOTE at the bottom of the description? Or add a "(not for JavaScript)" mini note? I can also make a "(
if (name == "ASDFGerte" && language == "JavaScript") { negativeZeroNote.Visible = false; }
)" if you want.But you still haven't supplied me with a code example...
Whoops, made a mistake myself. You will have slightly incostent tests across the different kata versions because not all languages support duck-typing.
Apart from that, you can forget about all this nonsense about
±0
. Technically, numbers in JS are floats, but in reality they are integers, even though they use float division instead of integer division and can't go beyond2^53 - 1
without "losing precision".I don't know which languages don't use integers, since I didn't make the translations and don't know most of the programming languages.
I don't have time right now to go through all of them one at a time.
This comment is hidden because it contains spoiler information about the solution
Added the extra decimal point test cases for JavaScript. Any feedback on them?
This comment is hidden because it contains spoiler information about the solution
Because they yield the same value. Even if you keep crying about how +0 and -0 are not identical, they still yield the same value even in binary representation:
Sorry, but this is unrelated here.
It actually says
"Zero can't be negative"
. Unfortunately, this is not 100% true in JS; fortunately, JS still thinks they are the same. You want to follow the spec so much? Your choice, but don't make a fuss of how "you're correct and others are wrong".Interesting statement, may I ask you what is this issue you're talking about? JavaScript is comparing values, not some magical being behind the curtains. If JS thinks that
-0 === +0
, then maybe-0
and0
are actually the same value (wow unexpected, such impossible)? Of course, you may not agree that zero equals zero, but in this case are you sure you should be talking about it here?https://en.wikipedia.org/wiki/IEEE_754
We are talking about integers, not floating-points or whatever else.
See also: https://en.wikipedia.org/wiki/Signed_zero
But yes as FArekkusu said,
Test.assertEquals(-0, 0);
will result in the test passing.Only place this might be an issue is for those weird programming languages that don't have integers.
I only know of Haskell, but do let me know if there are more in this Kata that need decimal point tests.
The values are checked for equality, not being identical. Yes,
-0
and+0
are not identical, andObject.is(-0, +0)
givesfalse
as a proof, but they are still equal to the same value -0
. Stop talking nonsense.Negative zero is a mathematical impossibility. The note in the description is mostly just so people wouldn't ask about it, yet here we are again.
There is already a test case for zero in Javascript, so I don't know what you are trying to say.
This comment is hidden because it contains spoiler information about the solution
Loading more items...