Answer the question
In order to leave comments, you need to log in
How to compare float arduino?
I am writing a power supply control system. I need to compare two float numbers: the voltage setting and the current voltage.
if(this_voltage <= voltage){
// Подкручиваем напряжение
}
Answer the question
In order to leave comments, you need to log in
The simplest solution is to reduce to an integer with the required accuracy.
Something like this (perhaps the bit depth of the integer will need to be increased):
#define ACCURACY 100.0
if (((int) (this_voltage*ACCURACY))<= ((int) (voltag*ACCURACY))){
// Подкручиваем напряжение
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question