GetExp Function

Purpose

Determines the exponent of the base of two

Syntax

int = GetExp(exp)

exp:floating-point expresssion

Description

GetExp() determines the exponent of the base of two. It is part of a set of three functions, GetExp(), LdExp() and Mant(), that break down a floating-point value.

The GetExp() and Mant() correspond to the frexp C-function, which breaks down the floating-point value (exp) into a mantissa (m) and an exponent (n), such that the absolute value of m is greater than or equal to 0.5 and less than 1.0, and x = m*2n. The integer exponent n is obtained using GetExp() and m with Mant().

LdExp(m, exp) computes a real number from the mantissa and exponent.

Example

Debug.Show

Local Double a, b, i, c, x

Trace GetExp(197)               // Prints 8

a = GetExp(197)

Trace Mant(197)                 // Prints 0.76953125

b = Mant(197)

c = LdExp(a, b)

Trace c                         // Prints 197

x = 111

Trace 2 ^ GetExp(x) * Mant(x)   // Prints 111

Remarks

See Also

LdExp(), Mant()

{Created by Sjouke Hamstra; Last updated: 07/10/2014 by James Gaite}