CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

help with atof and exponential string format

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rkrch



Joined: 29 Jul 2013
Posts: 1

View user's profile Send private message

help with atof and exponential string format
PostPosted: Mon Jul 29, 2013 2:57 pm     Reply with quote

i am a newbie and i have a problem with the following code.
I am running it on a PIC18F8722 using CCS and an ICD ..
output is 2.309e03..looks like the exponential part is not being considered or discarded...how can i correct the code?

float x;
char s = "2309.12e15";
x = atof(s);
printf("x = %e\n",x);
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Jul 29, 2013 3:52 pm     Reply with quote

are you sure your char array input , correctly terminates with an ASCII Z??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 29, 2013 4:17 pm     Reply with quote

Where's your array ? Make 's' into an array by adding the brackets
shown in bold below and see what happens.
Quote:
float x;
char s[] = "2309.12e15";
x = atof(s);
printf("x = %e\n",x);
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group