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 support@ccsinfo.com

Floating point using fprintf

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







Floating point using fprintf
PostPosted: Thu Jul 17, 2003 3:45 pm     Reply with quote

When using printf to print out a Floating point number, the number seems to be left justified and does not always have the proper number of digits to the right of the decimal point.

My code looks something like this:
as I am converting from hex to float and multiplying:

unsigned int32 fr0;
float freq, frequint;
unsigned int freq_num;

freqint = fr0;
freq = freqint * .005;
printf(LCD_PUTC, "Freq \%1x \%08.2f",freq_num, freq);

I'm using CCS C Compiler version 3.119
Is this problem fixed yet?
Thanks,
Don
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516112
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

Re: Floating point using fprintf
PostPosted: Thu Jul 17, 2003 7:25 pm     Reply with quote

:=When using printf to print out a Floating point number, the number seems to be left justified and does not always have the proper number of digits to the right of the decimal point.
:=
:=My code looks something like this:
:= as I am converting from hex to float and multiplying:
:=
:=unsigned int32 fr0;
:=float freq, frequint;
:=unsigned int freq_num;
:=
:=freqint = fr0;
:=freq = freqint * .005;
:=printf(LCD_PUTC, "Freq \%1x \%08.2f",freq_num, freq);
:=
:=I'm using CCS C Compiler version 3.119
:=Is this problem fixed yet?
:=Thanks,
:=Don

It works OK with 3.158.
Automatic typecasting works too, although I think I had problems in the past, and have done it manually since to make sure:
freqint = (float) fr0;
My understanding is poor on this point though.
Regards
Kenny
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516119
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