SW006010 Microchip Technology, SW006010 Datasheet - Page 110

no-image

SW006010

Manufacturer Part Number
SW006010
Description
MPLAB 17C SOFTWARE
Manufacturer
Microchip Technology
Datasheets

Specifications of SW006010

Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC17C
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
MPLAB®
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
MPLAB
5.4
apRNOVS^-page 106
DECIMAL/FLOATING POINT AND FLOATING POINT/DECIMAL
CONVERSIONS
C17 C Compiler Libraries
The details of how decimal numbers are converted to floating point numbers and how
floating point numbers are converted to decimal numbers are discuss in the following
sections.
5.4.1
There are several methods that will allow the conversion of decimal (base 10) numbers
to Microchip floating point format. Microchip provides a PC utility called FPREP.EXE,
which will convert decimal numbers to floating point for use in the math library routines.
This utility may be download from the Microchip web site along with the AN575 source
code.
Alternatively, the floating point equivalent to decimal numbers may be calculated long-
hand. To calculate the floating point via a longhand method, both the exponent and
mantissa must be found.
To find the exponent, the following formulae are used:
EQUATION 5-1:
EQUATION 5-2:
where Z is the fractional exponent, A
integer portion of Z.
To solve for the exponent, first begin by rearranging Equation 5-1 to solve for Z.
The absolute value of Z is then rounded to the next larger absolute value integer to yield
the value of Exp. Finally a bias value of 0x7F is added to convert Exp to Microchip
floating point format.
Next, the mantissa is determined. The exponent value just determined must be
removed from the original decimal number, using division.
EQUATION 5-3:
where x is the fractional portion of the mantissa, and A
above.
To determine the binary representation of the mantissa, x is compared in turn to
decreasing powers of 2, starting with 2
equal to the power of 2 currently being compared, a ‘1’ is placed in the corresponding
bit position of the binary representation and the power of 2 value is subtracted from x.
2
Exp
Z
x
Z
=
Note: x will always be a value greater than 1.
=
=
A
-------- -
------------------ -
=
ln
2
A
ln
10
Z
(
int Z ( )
10
A
Converting Decimal to Microchip Floating Point
2 ( )
10
)
10
0
is the original decimal number, and Exp is the
and decreasing to 2
10
and Z are values as described
 2002 Microchip Technology Inc.
-23
. If x is greater than or

Related parts for SW006010