| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Calculates the exponent of a floating point number.
Exponent( <nFloat> ) --> nExponent
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.
| See also: | Mantissa() |
| Category: | CT:NumBits , Numbers and Bits |
| Source: | ct\exponent.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com