A "random()" function which can probably be useful from time to time. It requires at least one entry as a boundary and returns a random integer between it and the second one (~ 0 if you used just one entry).
There is still one thing that bugs me: even though you are able to use any positive and negative number as an input, it currently just calculates the result correctly if none of them got floating points. I know there would be the possibility to check if one contains some (=> c = (a%1!=0)||(b%1!=0) ), but unfortunately I ran out of space. Since there seem to be the potential saving some bytes, e.g. like the condition for the second parameter check, there is hopefully the chance to enhance it. It would be great if you have an advice to shorten the code or know or nice way of determining the amount of floats :)
- thanks @tsaniel: pointing to keeping the scope, not counting the function name and regarding parantheses (140->112)
A little reordering saves two bytes:
return 0|Math.random()*(b-a+1)+a
Edit: Whoops, that appears to be one off for negative numbers...