# dtostrf return NANO

I'm using the dtostrf instruction to convert a float variable to string , but sometimesthe result returns the NANO string.

A that is because of?, That condition returns NANO?

I need to know when it returns this string to debug that time.

Can you post an example that duplicates the error?

This is the function:

void Estacionarias(){
//Calculo ROE
Dirroe = sqrt (Directa);
Refroe = sqrt (Reflejada);
Roe = (Dirroe+Refroe)/(Dirroe-Refroe);
lcd.SET_FontSize(2);
dtostrf(Roe, 1, 2, Roetxt);
lcd.WriteText(3,5,Roetxt,1);
delay(25);
lcd.WriteText(3,9,":1",1);
if (Roe > 2.90){
Alarma_roe();
}

Do you mean "NaN", aka "Not a Number"?

What are you feeding it?

``````     Roe = (Dirroe+Refroe)/(Dirroe-Refroe);
``````

What happens if Dirroe and Refroe are the same? Don't you think that you should check that?

Ok, this formula calculates ROE (standing waves relationship) of RF transmission line.
Dirroe and Refroe are equal at the time of start of the calculation, then they are never the same, always Dirroe 100 times Refroe.

But when results are NOT A NUMBER, in the beginning the two values ??are zero.

Thank you.

Good catch, Paul...

The solution has been:

if (Dirroe==Refroe) Roe=1.00;

ea5elf:
The solution has been:

if (Dirroe==Refroe) Roe=1.00;

But when results are NOT A NUMBER, in the beginning the two values ??are zero.

So, divide by 0 doesn't work. I'm not surprised.