Cannot convert from double to float


I need to change variable from double to float but I can’t.

	private double differentiate(double phase, double noise, double naturalFrequency) {
   //float AvPh= averagePhase;
   // float Ph= phase;
    float AvPhaMinusphase= (float) averagePhase- phase* 1;
		double phaseDerivative = naturalFrequency 
				+ noise
				+ coupling * orderParameter * PApplet.sin(AvPhaMinusphase);

		return phaseDerivative;

How can I transform double in float?

Thanks u

1 Like


return (float) phaseDerivative;
1 Like

Thanks it works <3.

To read float (if you multiply *0.1 for example) in array of double add f like this:

double AvPhaMinusphase = averagePhase- phase* 1f;