Calculating negative numbers with decimals


good evening all

i seem have problem knowledge operation of arduino.

i trying calculate following value, serial monitor round zero. ideas on how can go calculating correct values , using them in arduino?

float m = (1-40)/(1200-700);

by way, tried both leonardo , nano...

cheers
adam

the values integers, calculation done integer division. -39/500 = 0.
force done floating point (there various ways):
code: [select]
float m = (float)(1-40)/(float)(1200-700);

pete


Arduino Forum > Using Arduino > Programming Questions > Calculating negative numbers with decimals


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'