you must prevent that the value you check can be changed while you are comparing this value.
so turn off any interrupt that can alter the value.
then for singles/doubles : if you do an exact compare like : if somesingle = 1.2345 then it will lead to problems easily because the values compared must match for all bits.
123.45 is not 123.4500001. while fusing() can round the visible value, it will not round the actual value.
you say the problem exists with integers too : better supply a smal(ler) samples using integers.
but to test the current code :
- turn off interrupts that alter the value to check
- print the value and also the other variables used in the comparison
- when you have some know values, does it fail in the simulator too?
↧