Subject: atof() limitation?
To: None <netbsd-help@NetBSD.org>
From: Madhvesh R S <madhvesh.s@ap.sony.com>
List: netbsd-help
Date: 11/18/2004 11:24:12
Hi,
I am using NetBSD v1.6. The below sample program uses
atof() function call. When input is provided as hex
numbers, this atof() function fails. Is this a limitation
of atof() in NetBsd? I noticed in strtod.c implementation
that, it does not support hex numbers. Which version of
NetBSD supports atof() for hex inputs?
Thanks in advance
-MS
Test Program
===========================================================================
#include <stdlib.h>
#include <stdio.h>
int main()
{
char actualinput[20][20] = {"123456", "-123456","123.456","-123.456","1223
sdsdsad","12ac234", "\0", "0xa", "0x8", "0x01"};
double expectedoutput[] = { 123456, -123456, 123.456, -123.456, 1223,
12, 0, 10, 0x8, 1};
int counter;
double ret_value;
for(counter = 0; counter < 10; counter++)
{
ret_value = atof (actualinput[counter]);
if (ret_value == expectedoutput[counter])
{
printf ("\n\n\t\t<< t-atof.c TEST PASS >>\n\n\n");
}
else
{
printf ("\n\n\t\t<< t-atof.c TEST FAIL >>\n\n\n");
}
printf("input=%s\natof() returned = %f\nexpected output =
%f\n\n",actualinput[counter], ret_value, expectedoutput[counter]);
}
return 0;
}
============================================================================
========