FUNCTIONS CORE

Exponent()

Calculate the exponent of a floating point number

Syntax

Signature
Exponent( nFloat ) --> nExponent

Arguments

nFloat

Example

Exponent.prg
PROCEDURE Main()

   Check( 'Exponent( 0 )     ', Exponent( 0 ), 0 )
   Check( 'Exponent( 100 )   ', Exponent( 100 ), 6 )
   Check( 'Exponent( -100 )  ', Exponent( -100 ), 6 )
   Check( 'Exponent( -1.01 ) ', Exponent( -1.01 ), 0 )
   Check( 'Exponent( -2.01 ) ', Exponent( -2.01 ), 1 )
   Check( 'Exponent( 0.01 )  ', Exponent( 0.01 ), -7 )
   Check( 'Exponent( -0.01 ) ', Exponent( -0.01 ), -7 )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

Exponent( 0 )     OK
Exponent( 100 )   OK
Exponent( -100 )  OK
Exponent( -1.01 ) OK
Exponent( -2.01 ) OK
Exponent( 0.01 )  OK
Exponent( -0.01 ) OK