![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Oktay Guest
|
floating error |
Posted: Tue Jun 03, 2003 5:36 am |
|
|
Hi,
I have CCS PCM compiler ver 3.088
but floating point error
#define f1 1.41
#define f2 2.76
#define f3 3.14
printf(lcd_putc,"\%\f1.2f \%1.2f \%1.2f",f1,f2,f3);
On Display
1.40 2.75 3.14
Why?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515001 |
|
![](templates/subSilver/images/spacer.gif) |
Steve H. Guest
|
Re: floating error |
Posted: Tue Jun 03, 2003 9:41 am |
|
|
A PIC isn't a PC with unlimited resources and double precision math. You are trying to shove a decimal number into a limited precision binary representation. Without rounding errors you are lucky to get 3 digits.
For precise outputs you should consider using fixed point math with int's or long's and add the decimal point for the user display only.
This topic has been covered before on this board, search fixed point, float error, rounding, etc.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515006 |
|
![](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
|