![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
sonomadb Guest
|
Floating point using fprintf |
Posted: Thu Jul 17, 2003 3:45 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
Re: Floating point using fprintf |
Posted: Thu Jul 17, 2003 7:25 pm |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|