Searching \ for '[PIC]: Isolating Decimal Portion of Floating Point' in subject line. ()
Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=port
Search entire site for: 'Isolating Decimal Portion of Floating Point'.

Exact match. Not showing close matches.
'[PIC]: Isolating Decimal Portion of Floating Point'
2003\06\04@081913 by

I'm in the process of changing all my floating points to fixed point
numbers, but there are a few I need to stick with the
floating point.

Anyways, I have one particular floating point number which needs to be
broken down to the following format to be
displayed on an LCD screen:

XXXX feet, XX.X inches

Using the printf command, its easy to divide the floating point by 12, (i.e.
%04.0f) to get the XXXX feet portion, but
is there an easy way to extract the remainder of the divide by 12
operation???

So that:

Floating Point:  12152 inches

Broken down to:  1012 FT 08.0 IN

Using an integer is easy by using the Modulus function, however not so with
floating point.

Dan

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body
On Wed, 4 Jun 2003 08:18:27 -0400, you wrote:

>I'm in the process of changing all my floating points to fixed point
>numbers, but there are a few I need to stick with the
>floating point.
>
>Anyways, I have one particular floating point number which needs to be
>broken down to the following format to be
>displayed on an LCD screen:
>
>XXXX feet, XX.X inches
Just because it needs to be displayed with a DP doesn't mean you need FP. A little extra code to split it up for display will probably greatly outweigh the code savings from
not using FP in calculations. For example if you work in 24.8 fixed point in feet, this gives a range of 16 million feet with a
resolution of 1/256 inch.
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body
On Wed, 4 Jun 2003 13:26:16 +0100, you wrote:

>On Wed, 4 Jun 2003 08:18:27 -0400, you wrote:
>
>>I'm in the process of changing all my floating points to fixed point
>>numbers, but there are a few I need to stick with the
>>floating point.
>>
>>Anyways, I have one particular floating point number which needs to be
>>broken down to the following format to be
>>displayed on an LCD screen:
>>
>>XXXX feet, XX.X inches
>Just because it needs to be displayed with a DP doesn't mean you need FP.
>A little extra code to split it up for display will probably greatly outweigh the code savings from
>not using FP in calculations.
>For example if you work in 24.8 fixed point in feet, this gives a range of 16 million feet with a
>resolution of 1/256 inch. oops, that should be 1/256 feet, or about 0.05 inch. Of course unless you're navigating a spacecraft
you probably don't need a range of 16 million feet so just move the point to where you get enough
resolution.
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...