Mantissa()

Mantissa()

Evaluate the mantissa of a floating point number

Syntax

       Mantissa( <nFloatingPointNumber> ) --> nMantissa

Arguments

<nFloatingPointNumber> Designate any Harbour number.

Returns

Mantissa() returns the mantissa of the <nFloatingPointNumber> number.

Description

This function supplements Exponent() to return the mantissa of the <nFloatingPointNumber> number.

Notes

The mantissa value can be 0 or in the range of 1 to 2. The following calculation reproduces the original value: Mantissa( <nFloatingPointNumber> ) * 2 ˆ Exponent( <nFloatingPointNumber> ) = <nFloatingPointNumber>

Example

       Display the mantissa for the following values:
           ? Mantissa(0)            // Result:  0.00
           ? Mantissa(100)          // Result:  1.56
           ? Mantissa(INFINITY)     // Result:  2.00
           ? Mantissa(0.01)         // Result:  1.28
           ? Mantissa(-100)         // Result: -1.56
           ? Mantissa(-0.01)        // Result: -1.28
           ? Mantissa(-1.01)        // Result: -1.01
           ? Mantissa(-2.01)        // Result: -1.01

Compliance

Mantissa() is compatible with CT3’s Mantissa().

Platforms

All

Files

Source is exponent.c, library is libct.

Seealso

Exponent()

CT_EXPONENT

 EXPONENT()
 Determines the exponent of a floating point number (base 2)
------------------------------------------------------------------------------
 Syntax

     EXPONENT(<nFloatingPointNumber>) --> nExponent

 Argument

     <nFloatingPointNumber>  Designates any decimal number.

 Returns

     EXPONENT() returns the exponent of the <nFloatingPointNumber> number in
     base 2.

 Description

     Clipper stores all numbers in a floating point format (called
     "double" in C).  EXPONENT() only returns exponents in this format, and
     they are always expressed in base 2.

 Note

     .  The expression EXPONENT(0) returns a value of 0.  However, the
        expression 20 returns a value of 1.  In this case, the mantissa must
        also equal 0 (see MANTISSA()).

 Examples

     .  The following calculation produces the original number:
        ^2 EXPONENT(nValue) * MANTISSA(nValue)= nValue

        ? EXPONENT(0)                     // Result:  0
        ? EXPONENT(INFINITY())            // Result:  1023
        ? EXPONENT(100)                   // Result:  6

     .  The sign for nValue will not be considered:

        ? EXPONENT(-100)                  // Result:  6
        ? EXPONENT(-1.01)                 // Result:  0
        ? EXPONENT(-2.01)                 // Result:  1

     .  Values in the range of -1 < nValue < +1, yield negative
        exponents regardless of the sign:

        ? EXPONENT(0.01)                  // Result:  -7
        ? EXPONENT(-0.01)                 // Result:  -7

See Also: MANTISSA()

 

Tools – Numbers/Bit Manipulation

Introduction
BITTOC()     Converts position-dependent bits into characters
CELSIUS()    Converts a Fahrenheit temperature value into Celsius
CLEARBIT()   Clears one or more bits within a number to zero
CTOBIT()     Converts a character string into a bit pattern
CTOF()       Converts a special 8-byte string into a floating point number
CTON()       Converts a numeric string into a different base
EXPONENT()   Determines the exponent of a floating point number (base 2)
FAHRENHEIT() Converts a temperature value from Celsius into Fahrenheit
FTOC()       Converts a floating point number into a special 8-byte string
INFINITY()   Creates the largest number possible (21023)
INTNEG()     Converts an unsigned integer into a signed integer
INTPOS()     Converts a signed integer into an unsigned integer
ISBIT()      Tests the bits in a number
LTON()       Converts a logical value into a numeric value
MANTISSA()   Determines the mantissa of a floating point number (base2)
NTOC()       Converts numbers in a digit string into a different number base
NUMAND()     Performs a 16-bit "AND" of a list of numbers
NUMCOUNT()   Uses the internal CA-Clipper Tools counter
NUMHIGH()    Returns the higher value byte in a 16-bit number
NUMLOW()     Returns the lower value byte in a 16-bit number
NUMMIRR()    Mirrors 8-bit or 16-bit values
NUMNOT()     Performs a 16-bit "NOT" of a number
NUMOR()      Performs a 16-bit "OR" of a list of numbers
NUMROL()     Performs a 16-bit left rotation of a number
NUMXOR()     Performs a 16-bit "XOR" of two numbers
RAND()       Generates random numbers
RANDOM()     Generates random numbers
SETBIT()     Sets one or more bits in a number