What about integers?
Often you will want to generate a random integer value. For example, if you are simulating a die roll. To do this, we'll need to using casting (see variables) to convert it to an integer. Remember that it truncates the value, so be careful you don't end up off by one.
((int) (Math.random() * 5)) + 2 // generates an int between 2 and 6
In addition, you want to be careful that you multiply Math.random() by the scalar before casting it to an integer. If you cast the base value - which is between 0 inclusive and 1 exclusive - to an integer, it will always be zero.