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
Post a Comment