Closed GoogleCodeExporter closed 9 years ago
if you put '(float)' just before the calculation then the answer is more like
expected.
float xy = (float)x/y;
http://arduino.cc/en/Reference/Float
Original comment by pejo.D...@gmail.com
on 2 Nov 2011 at 5:03
Yeah, as pejo says, if you divide two integral types (like long) the result
will be a long (or int), even if you then store that result into a float.
That's just how C does it. If you want a floating point result, you need to
convert one of the two numbers to a float before doing the division.
Original comment by dmel...@gmail.com
on 2 Nov 2011 at 7:08
Thanks for your assistance and the lesson in C.
Original comment by johnk36...@hotmail.com
on 3 Nov 2011 at 4:43
Thanks for your assistance and the lesson in C.
Original comment by johnk36...@hotmail.com
on 3 Nov 2011 at 4:45
Original issue reported on code.google.com by
johnk36...@hotmail.com
on 2 Nov 2011 at 2:32