[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] atof routine
From: |
Colin O'Flynn |
Subject: |
Re: [avr-libc-dev] atof routine |
Date: |
Thu, 17 Apr 2003 16:54:08 -0700 (PDT) |
Hello,
I just finished doing some tests, and they seem to
work! The code used to test it was:
------BEGIN TEST CODE------
#include <stdlib.h>
#define atof(s) strtod(s, (char **)0)
(other includes, main definition)
while(1){
send_string_P(PSTR("\nInput:"));
counter = 0;
do
{
message[counter] = input_ch_1();
output_ch_1(message[counter]);
}while (message[counter++] != '\r');
message[counter - 1] = '\0';
dtostre(atof(message), message, 6, 0);
send_string_P(PSTR("\nOutput:"));
send_string(message);
}
(other code such as send_string)
---END TEST CODE----
And here are the results:
---BEGIN RESULTS---
Atmel AVR RISC Processor
Input:1.249034
Output:1.249034e+00
Input:-1.249034
Output:-1.249034e+00
Input:10000000000000000000000000000
Output:1.000001e+28
Input:-10000000000000000000000000000
Output:-1.000001e+28
Input:19999999999999999999999999999
Output:2.000003e+28
Input:02
Output:2.000000e+00
Input:0000000022.5893845
Output:2.258938e+01
Input:a
Output:0.000000e+00
Input:12309BCD1230
Output:1.230900e+04
Input:-1000000000002498609
Output:-9.999983e+17
Input:-1000043
Output:-1.000043e+06
Input:1.235930
Output:1.235930e+00
Input:9.32414
Output:9.324141e+00
Input:9.33333
Output:9.333332e+00
Input:33333333
Output:3.333334e+07
Input:123
Output:1.230000e+02
Input:-87347293
Output:-8.734734e+07
Input:00001
Output:1.000000e+00
Input:10000
Output:1.000000e+04
Input:+0001
Output:1.000000e+00
Input:-0001
Output:-1.000000e+00
Input:+934.4320682
Output:9.344322e+02
---End results---
The results are the capture of the terminal emulator
program. The Input: is the number I told it to
convert, the output: is the actual result.
I didn't detect any failures, they all looked correct
and the resulting floating point numbers very close
representations of the real number.
Regards,
-Colin
--- Joerg Wunsch <address@hidden> wrote:
> As Colin O'Flynn wrote:
>
> > >#define atof(s) strtod(s, (char **)0)
> >
> > Hmm THAT is certainly easier,
>
> I thought so. :-)
>
> Maybe we should even include that #define.
>
> > Or move the routine up with the rest of the strtoX
> > routines, as I looked there, then looked down at
> the
> > bottem with the unimplemented routines.
>
> Hmm, i'll have a look there. Why didn't you browse
> the docs? I
> thought it is documented...
>
> > I noticed the routine says: implemented, but not
> yet
> > tested. I could do a bit of quick testing (writing
> > values and reading them out basically).
>
> This comment might be out of date, but please do.
> If we get
> positive feedback from you, we'll delete that
> remark.
>
> --
> J"org Wunsch Unix support engineer
> address@hidden
> http://www.interface-systems.de/~j/
>
>
> _______________________________________________
> AVR-libc-dev mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/avr-libc-dev