# Cannot convert from double to float

**URL:** <https://discourse.processing.org/t/cannot-convert-from-double-to-float/10427>\
**Category:** Beginners\
**Created:** [April 18, 2019, 2:08pm UTC](https://discourse.processing.org/t/cannot-convert-from-double-to-float/10427 "2019-04-18T14:08:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [April 18, 2019, 2:08pm UTC](https://discourse.processing.org/t/cannot-convert-from-double-to-float/10427/1 "2019-04-18T14:08:07Z")

</div>

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

```auto
	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

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 18, 2019, 2:49pm UTC](https://discourse.processing.org/t/cannot-convert-from-double-to-float/10427/2 "2019-04-18T14:49:06Z")

</div>

> [@bking](#):
>
> return phaseDerivative;

Try

```auto
return (float) phaseDerivative;

```

---

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [April 18, 2019, 8:28pm UTC](https://discourse.processing.org/t/cannot-convert-from-double-to-float/10427/3 "2019-04-18T20:28:29Z")

</div>

Thanks it works \<3.

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

```auto
double AvPhaMinusphase = averagePhase- phase* 1f;

```
