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
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):
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
Post a Comment