|
|
View previous topic :: View next topic |
Author |
Message |
ryan.reeve
Joined: 23 Jul 2006 Posts: 20
|
single precision FP |
Posted: Sun Oct 08, 2006 10:06 pm |
|
|
what is meant by single precision Floating Point and Double precision Floating Point .Does CCS support double precsion float ? |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 09, 2006 4:34 am |
|
|
Originally, the terms were fairly meaningless, being used on different platforms/machines, to refer to different precisions. However quite a long time ago (about 20 years now), the IEEE generated some 'standards' for these, and this is what is now generally used. Single precision floating point, now, normally refers to using 4 bytes total for each value, with a 24 bit mantissa (of which 23 bits are stored), a sign bit, and an 8 bit exponent. This gives an equivalent accuracy of about 6.5 decimal digits. Double precision, uses 8 bytes for the value, with a 53 bit mantissa, giving 15+ decimal digit accuracy.
CCS C, supports single precision FP. This is all that was supported by the original C implementations.
Seriously, maths libraries for FP are _big_, and slow. except for the newer vey large PICs, a DP library would probably be fairly impractical on these chips.
It is also worth being very aware, of both the abilities, and limitations of FP arithmetic. For example, a single precision FP number, could potentially represent the circumference of the Earth, to within about 16 feet. Conversely though, _any FP storage form, is not suitable for applications dealing with finance for example, where the inherent internal rounding errors, will lead to faults. This is why using a 'scaled integer', is the standard practise for this.
If you want arithmetic beyond the limits of FP, then consider actually attaching a calculator chip (effectively a 'maths co-processor'). I dis this some years ago, on an early PIC, as a way of avoiding the need for the bulk of the FP code.
Best Wishes |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Mon Oct 09, 2006 7:35 am |
|
|
While we're on the topic, why doesn't CCS use the IEEE standard format for single float? It would be handy to transfer binary floats between the PIC and a PC or some other processor. I'm guessing there is a speed advantage?
Ken |
|
|
Sherpa Doug Guest
|
|
Posted: Mon Oct 09, 2006 7:54 am |
|
|
Long long ago when Microchip introduced the PIC14000 chip they created assembly language libraries to go with it that included FP functions. These libraries may have even predated the IEEE standards. CCS then adopted the Microchip standard.
SherpaDoug |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Mon Oct 09, 2006 6:32 pm |
|
|
The PC to PIC float transfer may require some caution. It is true single precision is a 24 bit (mantissa and sign) and an 8 bit exponent( offset to encode positive and negative powers). There may be little endian big endian issues and with Microsoft code there is hot dogging to be aware of. The binary mantissa is normalized so unaltered it will always have leading 1. Hot dogging is replacing the 1( which is always implied) with the sign to acquire 24 bit precision instead of 23 bit. |
|
|
|
|
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
|