Previous Page Table of Contents Index Next Page

Palm OS SDK Reference


Palm Logo 31 Float Manager

This section provides reference material for the float manager. The float manager API is declared in the header file FloatMgr.h.

For more information on the float manager, see the section "Floating-Point" in the Palm OS Programmer's Companion.

Float Manager Functions




FplAdd

Purpose

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

Prototype

FloatType FplAdd (FloatType a, FloatType b)

Parameters

  a, b
The floating-point numbers.

Result

Returns the normalized floating-point result of the addition.

Comment

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.



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

  s
Pointer to the ASCII string.

Result

Returns the floating-point number.

Comment

The mantissa of the number is limited to 32 bits.

See Also

FplFToA



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

  a
The floating-point number.
  mantissaP
The base 10 mantissa (return value).
  exponentP
The base 10 exponent (return value).
  signP
The 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

  dividend
Floating-point dividend.
  divisor
Floating-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.



FplFloatToLong

Purpose

Convert a floating-point number to a long integer.

Prototype

Long FplFloatToLong (FloatType f)

Parameters

  f
Floating-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

  f
Floating-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

 

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.yyyyyyyye[-]zz

Prototype

Err FplFToA (FloatType a, char* s)

Parameters

  a
Floating-point number.
  s
Pointer to buffer to contain the ASCII string.

Result

Returns an error code, or 0 if no error.

See Also

FplAToF



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

  x
A long integer.

Result

Returns the floating-point number.



FplMul

Purpose

Multiply two floating-point numbers.

Prototype

FloatType FplMul (FloatType a, FloatType b)

Parameters

  a, b
The floating-point numbers.

Result

Returns the normalized floating-point result of the multiplication.

Comment

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.



FplSub

Purpose

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

Prototype

FloatType FplSub (FloatType a, FloatType b)

Parameters

  a, b
The floating-point numbers.

Result

Returns the normalized floating-point result of the subtraction.

Comment

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.


Palm OS SDK Reference

  Previous Page Table of Contents Index Next Page  

This is page 33 of 85 in this book

Palm Computing Platform Development Zone
Copyright © 2000, Palm, Inc. All rights reserved.