dtostrf hangs with nan and inf
This hangs; a nan obtained via sqrt(-1.0) also hangs. The culprit is "fcvtf(val, precision, &decpt, &sign);" used by dtostrf. sprintf handles this properly and prints 'inf'.
Code:
// standard Blink example
...
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
volatile float zero = 0.0;
char buffer[200];
float fval = 1 / zero;
dtostrf(fval,2,0,buffer);
}
This hangs; a nan obtained via sqrt(-1.0) also hangs. The culprit is "fcvtf(val, precision, &decpt, &sign);" used by dtostrf. sprintf handles this properly and prints 'inf'.
Last edited: