My JavaScript random number is always initialized to 1? -


Can anyone help me in troubleshooting this problem? In the code below, circus and circy are being started appropriately, but theta always starts with 1! Console log theta = 1 every time I load the page.

  var circx = Math.floor (Math.random (* * number.MAX_VALUE)% papwidth; Var circy = Math.floor (Math.random (* * Number MAX_VALUE)% papheight; / * Circus, Circuit: The initial position of the circle on the paparizer * / var mycirc = paper.circle (circuses, cerci, 10); mycirc.attr ("filling", "# f9c624"); var theta = math.flur (math .Rendum () * no.mx_avnaa% 4 + 1; / * theta = 1 <---> Object is going to 45-degree angle theory = 2 <---> Object Going on 135-degree angle theta = 3 <---> Object is going to 225 degree angle atta = 4 <---> Object It is growing at a 315 degree angle * / console.log ("theta =" + theta);   

It does not make any sense!

  & gt; Math.random () * number. MX_Vision 8.365923028455995e + 307   

You can see that E + 307 means that it ends in zero 307. Dubbles integer is not stored in exact, take that moded 4 and add 1 and you always get 1. (Or you do 99.99999 ...% of time).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -