1.0 Float Manager
 

 < Home   < Developers   < Development Support   < Documentation

C 1.0 Float Manager


 Table of Contents  |  < Previous  |  Next >  |  Index
   
   

Title -
Palm OS® Programmer's API Reference

Part V: Appendixes

C 1.0 Float Manager

Float Manager Functions

FplAdd

FplAToF

FplBase10Info

FplDiv

FplFloatToLong

FplFloatToULong

FplFree

FplFToA

FplInit

FplLongToFloat

FplMul

FplSub

       

This section provides reference material for the Palm OS 1.0 float manager. In Palm OS 1.0, the float manager API is declared in the header file FloatMgr.h. In Palm OS 2.0, this file was renamed to FloatMgrOld.h. In Palm OS 3.5, this file was made private.


NOTE: New applications should no longer use the 1.0 Float Manager. See Chapter 33, "Float Manager," for the functions now provided by the Float Manager.

Float Manager Functions

FplAdd

Purpose

Add two floating-point numbers (returns a + b).

Prototype

FloatType FplAdd (FloatType a, FloatType b)

Parameters

a, bThe floating-point numbers.

Result

Returns the normalized floating-point result of the addition.

Comments

Under Palm OS® 2.0 and later, most applications will want to use the arithmetic symbols instead. See the "Floating-Point" section in the Palm OS Programmer's Companion, vol. I.

FplAToF

Purpose

Convert a zero-terminated ASCII string to a floating-point number. The string must be in the format: [-]x[.]yyyyyyyy[e[-]zz]

Prototype

FloatType FplAToF (char* s)

Parameters

sPointer to the ASCII string.

Result

Returns the floating-point number.

Comments

The mantissa of the number is limited to 32 bits.

See Also

FplFToA , FplFree, FplInit

FplBase10Info

Purpose

Extract detailed information on the base 10 form of a floating-point number: the base 10 mantissa, exponent, and sign.

Prototype

Err FplBase10Info (FloatType a, ULong* mantissaP, Int* exponentP, Int* signP)

Parameters

aThe floating-point number.
mantissaPThe base 10 mantissa (return value).
exponentPThe base 10 exponent (return value).
signPThe sign, 1 or -1 (return value).

Result

Returns an error code, or 0 if no error.

Comments

The mantissa is normalized so it contains at least kMaxSignificantDigits significant digits when printed as an integer value.

FlpBase10Info reports that zero is "negative"; that is, it returns a one for xSign. If this is a problem, a simple workaround is:

    if (xMantissa == 0) { 
        xSign = 0; 

FplDiv

Purpose

Divide two floating-point numbers (result = dividend/divisor).

Prototype

FloatType FplDiv (FloatType dividend, FloatType divisor)

Parameters

dividendFloating-point dividend.
divisorFloating-point divisor.

Result

Returns the normalized floating-point result of the division.

Under Palm OS 2.0 and later, most applications will want to use the arithmetic symbols instead. See the "Floating-Point" section in the Palm OS Programmer's Companion, vol. I.

FplFloatToLong

Purpose

Convert a floating-point number to a long integer.

Prototype

Long FplFloatToLong (FloatType f)

Parameters

fFloating-point number to be converted.

Result

Returns the long integer.

See Also

FplLongToFloat, FplFloatToULong

FplFloatToULong

Purpose

Convert a floating-point number to an unsigned long integer.

Prototype

ULong FplFloatToULong (FloatType f)

Parameters

fFloating-point number to be converted.

Result

Returns an unsigned long integer.

See Also

FplLongToFloat, FplFloatToLong

FplFree

Purpose

Release all memory allocated by the floating-point initialization.

Prototype

void FplFree()

Parameters

None.

Result

Returns nothing.

Comments

Applications must call this routine after they've called other functions that are part of the float manager.

See Also

FplInit

FplFToA

Purpose

Convert a floating-point number to a zero-terminated ASCII string in exponential format: [-]x.yyyyyyye[-]zz

Prototype

Err FplFToA (FloatType a, char* s)

Parameters

aFloating-point number.
sPointer to buffer to contain the ASCII string.

Result

Returns an error code, or 0 if no error.

See Also

FplAToF, FplFree, FplInit

FplInit

Purpose

Initialize the floating-point conversion routines.

Allocate space in the system heap for floating-point globals.

Initialize the tenPowers array in the globals area to the powers of 10 from -99 to +99 in floating-point format.

Prototype

Err FplInit()

Parameters

None.

Result

Returns an error code, or 0 if no error.

Comments

Applications must call this routine before calling any other Fpl function.

See Also

FplFree

FplLongToFloat

Purpose

Convert a long integer to a floating-point number.

Prototype

FloatType FplLongToFloat (Long x)

Parameters

xA long integer.

Result

Returns the floating-point number.

FplMul

Purpose

Multiply two floating-point numbers.

Prototype

FloatType FplMul (FloatType a, FloatType b)

Parameters

a, bThe floating-point numbers.

Result

Returns the normalized floating-point result of the multiplication.

Comments

Under Palm OS 2.0 and later, most applications will want to use the arithmetic symbols instead. See the "Floating-Point" section in the Palm OS Programmer's Companion, vol. I.

FplSub

Purpose

Subtract two floating-point numbers (returns a - b).

Prototype

FloatType FplSub (FloatType a, FloatType b)

Parameters

a, bThe floating-point numbers.

Result

Returns the normalized floating-point result of the subtraction.

Comments

Under Palm OS 2.0 and later, most applications will want to use the arithmetic symbols instead. See the "Floating-Point" section in the Palm OS Programmer's Companion, vol. I.