I just wanted to create a random integer in the range <-1,1>
, that is -1, 0 or 1. I think this code nails it:
Math.round(Math.random()*2-1)
But I get another value besides -1, 0 and 1. I am not sure what this should be:
![image description](https://fooobar.com//img/9639d424575420a750ed440cf47d9936.png)
Now I do not think that this is an implementation error, but if so, I use Firefox 41, and the same thing happened in Google Chrome 39. When I tried to record -0
in the console, it looked like -0
but -0
, converted to String
, it displays like "0"
. What is it? Can I use it for something, for example, for some interesting software hacks and workarounds? Could this cause some errors if I don't just ignore it?
source
share