# problem with atof function

Created Mon, 01 Apr 2013 16:56:16 +0000 by rodsir

### rodsir

Mon, 01 Apr 2013 16:56:16 +0000

Hello,

I can not run the function atof. The program works with arduino but it does not work with a card Uno32.

``````double Frequence;
float Frequence1;

#include &lt;stdlib.h&gt;

void setup() {

Serial.begin(115200);
Frequence=0;
Serial.println("--------------------------------------------");
Frequence = atof("12.356");
Serial.println(Frequence);
Frequence = atof("12,356");
Serial.println(Frequence);
Serial.println("--------------------------------------------");
Frequence1 = atof("12.356");
Serial.println(Frequence1);
Frequence1 = atof("12,356");
Serial.println(Frequence1);
}

void loop() {
}
``````

### majenko

Mon, 01 Apr 2013 18:58:48 +0000

Confirmed - its not you, there is a problem there.

strtod() does the same - returns 0.00 every time.

### rodsir

Mon, 01 Apr 2013 19:56:46 +0000

Yes, the result is always 0.00. Why? How to solve the problem?

Thank you.

### majenko

Mon, 01 Apr 2013 22:55:28 +0000

I have raised it as an issue. It should get dealt with. Until then, you will have to look at manual parsing of the string.

Have two variables, both set to 0: total and divider.

Take the string a character at a time. If it's a digit, then multiply both the total and divider by 10 and add the digit to the total. If the character is a . then set the divider to 1.

When you reach the end of the string (say 12.345), you should end up with two values: 12345 and 1000. Divide the total by the divider, and you will end up with 12.345 as a float value.

### majenko

Tue, 02 Apr 2013 07:46:19 +0000

OK, this is a known bug, and has been fixed in a very recent test build.

I have confirmed that it works fine in mpide-0023-linux32-20130324-test - you can download the latest test build for your platform from: [url]http://chipkit.s3.amazonaws.com/index.html?sort=lastmod&sortdir=desc[/url]

### rodsir

Wed, 03 Apr 2013 09:47:26 +0000

Hello,

Thank you Majenko. Not having the opportunity to work in Linux, I went looking in the http://chipkit.s3.amazonaws.com/index.html?sort=lastmod&sortdir=desc mpide-0023-windows-20130203-test release. Now the program works. Another big thank you. :P