xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Exponent()

Calculates the exponent of a floating point number.

Syntax

Exponent( <nFloat> ) --> nExponent

Arguments

<nFloat>
Any numeric value can be passed.

Return

The function returns the exponent base 2 of a floating point number. It is used together with the Mantissa() for the binary representation of floating point numbers.

Info

See also:Mantissa()
Category: CT:NumBits , Numbers and Bits
Source:ct\exponent.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of Exponent() and shows
// how a number is calculated from its mantissa and exponent.

   PROCEDURE Main
      LOCAL nE, nM

      ? Exponent( -10 )      // result:    3
      ? Exponent(  -1 )      // result:    0
      ? Exponent(-0.1 )      // result:   -4
      ? Exponent(   0 )      // result:    0
      ? Exponent( 0.1 )      // result:   -4
      ? Exponent(   1 )      // result:    0
      ? Exponent(  10 )      // result:    3

      nE := Exponent( 10 )
      nM := Mantissa( 10 )
      ? nM * 2ˆnE            // result:   10.0000
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe