Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

frexp(3)  —  Subroutines

NAME

frexp, ldexp, logb, scalb − Manipulates floating-point numbers

LIBRARY

Math Library (libm.a)

SYNOPSIS

#include <math.h>

double frexp  (double x, int ∗n);
float  frexpf (float  x, int ∗n);
double ldexp  (double y, int n);
float  ldexpf (float  y, int n);
double logb   (double x);
float  logbf  (float  x);
double scalb  (double x, double n);
float  scalbf (float  x, float  n);

DESCRIPTION

Every nonzero number can be written uniquely as z times 2 raised to the power p, where the absolute value of the mantissa (fraction) z is in the range [0.5, 1.0), and the exponent p, is an integer. 

frexp() and frexpf() break a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the int object pointed to by the n parameter and returns the fraction part. 

ldexp() and ldexpf() multiply a floating-point number, y, by an integral power of 2. 

logb() and logbf() return a signed integer converted to double-precision floating-point and so chosen that 1 <= |x|/2∗∗n < 2 unless x = 0 or |x| = infinity or x lies between 0 and the Underflow Threshold. 

IEEE 754 defines logb(+infinity) = +infinity and logb(0) = -infinity.  The latter is required to signal Division-by-Zero. 

scalb() and scalbf() = x∗(2∗∗n) computed, for integer n. 

Function Exceptional Argument Routine Behavior
frexp(), frexpf() |x| = infinity invalid argument
logb(), logbf() |x| = infinity invalid argument
scalb(), scalbf() x∗(2∗∗n) > max_float overflow
scalb(), scalbf() x∗(2∗∗n) < min_float underflow
ldexp(), ldexpf() x∗(2∗∗n) > max_float overflow
ldexp(), ldexpf() x∗(2∗∗n) < min_float underflow

Value Name Data Type Hexadecimal Value Decimal Value
max_float F_FLOAT FFFF7FFF 1.701411e38
G_FLOAT FFFFFFFFFFFF7FFF 8.988465674311579e307
S_FLOAT 7F7FFFFF 3.402823e38
T_FLOAT 7FEFFFFFFFFFFFFF 1.797693134862316e308
min_float F_FLOAT 00000080 2.9387359e-39
G_FLOAT 0000000000000010 5.562684646268003e-309
S_FLOAT 00000001 1.4012985e-45
T_FLOAT 0000000000000001 4.940656458412465e-324

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026