Page 1 of 1

So confused - floating point math not working

PostPosted: Mon Nov 10, 2014 8:19 pm
by ATX_PICuser
I am seriously confused. I am working on a project that requires the use of a linearization equation and I can't get the equation to work properly because any number less than 1 is converted to a zero even when using data type of float.

In a nutshell this is what I have:

float corrected_pwm;
unsigned int a = 35;
unsigned int b = 50

corrected_pwm = 6 * (a/b);

The variable "corrected_pwm" always comes back as zero because the division step (a/b) is being rounded to zero.

Can someone explain to me how I should be doing this?

Re: So confused - floating point math not working

PostPosted: Tue Nov 11, 2014 2:37 am
by ric