Arduino calculating math incorrectly?

Serial.println(LightValue); Serial.println(LightValue/770*255);

552 0

while it should be

552 182.805

Why is this occurring?

nate890: Serial.println(LightValue); Serial.println(LightValue/770*255);

552 0

while it should be

552 182.805

Why is this occurring?

That is correct.

The problem is you are expecting floating point math, but telling the compiler that you want integer math:

Serial.println(LightValue);
Serial.println(LightValue/770.0*255.0);

Tried making it a double to see if it would work, would have made sense to make it a float.

Thanks!

Float and double are the same size for the Arduino

Really? Hm. What’s the point in having both then?

for the Arduino

That is not the case for other implementations of C/C++. The bigger the precision the more it takes to calculate, especially as there is no floating point hardware support. How many decimal places to you need?

"That is not the case for other implementations of C/C++." I know. But, since arduino's float counts as double and double counts as float, why have both?

Because the C++ standard requires both types.

nate890:
“That is not the case for other implementations of C/C++.”
I know. But, since arduino’s float counts as double and double counts as float, why have both?

Portability.