This site requires JavaScript, please enable it in your browser!
Greenfoot back
Hydrowarrior
Hydrowarrior wrote ...

2016/2/16

Possible lossy conversion rates from long to int

Hydrowarrior Hydrowarrior

2016/2/16

#
if(Greenfoot.isKeyDown("left")) { if(drift <= 3) { drift = drift * (-0.1); turn(Math.round(drift)); } } So that is the code that runs in the act method. The bolded section is where I get my error, " Possible lossy conversion rates from long to int" My number will always be an integer that isn't big enough where an int cannot hold the value. How would I convert a long into an int then?
Hydrowarrior Hydrowarrior

2016/2/16

#
Don't reply I figured it out, I needed to put (int) in front of Math.round.
You need to login to post a reply.