Cannot convert from float to int Processing/Java -


i have code here:

int mutate(float x){    if (random(1) < .1){    float offset = randomgaussian()/2;    float newx = x + offset;    return newx;  } else {     return x;   } } 

this code gives error on both samples of returning value saying "type mismatch: cannot convert float int." wrong code?

thanks in advance.

you need change return type float in order return decimal values (if that's interested in):

float mutate(float x){     if (random(1) < .1){         float offset = randomgaussian()/2;         float newx = x + offset;         return newx;     } else {         return x;      } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -