LdExp Function

Purpose

Computes a real number from the mantissa and exponent.

Syntax

int = LdExp(x, exp)

x: double expression
exp: iexp

Description

LdExp(x, exp) computes a real number from the mantissa and exponent. It is part of a set of three functions, GetExp(), LdExp() and Mant(), that break down a floating-point value.

The LdExp function returns the value of x * 2exp if successful.

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().

Example

OpenW 1

Local Double a, b, i, c, x

Print GetExp(197)

a = GetExp(197)

Print Mant(197)

b = Mant(197)

c = LdExp(a, b)

Print c                         // prints 197

x = 111

Print 2 ^ GetExp(x) * Mant(x)   // prints 111

Remarks

See Also

GetExp(), Mant()

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