immutable class FLT < $REAL_NUMBER{FLT}, $HASH, $FMT
****
IEEE 754-1984 "single" format 32-bit floating point. Most of these functions presently just call the FLTD versions because of C double/float calling convention weirdness; this is the most portable way.


Ancestors
$FMT $HASH $IS_EQ $REAL_NUMBER{_}
$NUMBER{_} $NFE{_} $STR $NIL
$IS_NIL $IS_LT{_} $FLT



Public


Constants
const digits:INT:=6;
**** The number of decimal digits of precision.
const double_inv_pi:SAME:=FLTD::double_inv_pi.flt;
**** Approximation of 2/pi
const double_sqrt_pi:SAME:=FLTD::double_sqrt_pi.flt;
**** Approximation of 2*(pi.sqrt).
const e:SAME:=FLTD::e.flt;
**** An approximation of the base of the natural logarithms "e".
const epsilon:SAME:=1.19209290e-07;
**** The minimum x>0.0 such that 1.0+x/=x.
const half_pi:SAME:=FLTD::half_pi.flt;
**** Approximation of pi/2.
const inv_pi:SAME:=FLTD::inv_pi.flt;
**** Approximation of 1/pi.
const inv_sqrt_2:SAME:=FLTD::inv_sqrt_2.flt;
**** Approximation of 1/(2.sqrt).
const log10_e:SAME:=FLTD::log10_e.flt;
**** Approximation of e.log10.
const log2_e:SAME:=FLTD::log2_e.flt;
**** Approximation of e.log2.
const log_10:SAME:=FLTD::log_10.flt;
**** Approximation of 10.log.
const log_2:SAME:=FLTD::log_2.flt;
**** Approximation of 2.log.
const mantissa_bits:INT:=24;
**** The number of bits in the significand, including an implied bit.
const max_exp10:INT:=38;
**** The maximum x such that 10^x is within range.
const max_exp:INT:=128;
**** The maximum allowable exponent.
const min_exp10:INT:=-37;
**** The minimum x such that 10^x is in the range of normalized floating point numbers.
const min_exp:INT:=-125;
**** The minimum negative integer x such that b^(x-1) is in the range of normalized floating point numbers.
const one: SAME := 1.0;
****
const pi:SAME:=FLTD::pi.flt;
**** An approximation of the mathematical value "pi".
const quarter_pi:SAME:=FLTD::quarter_pi.flt;
**** Approximation of pi/4.
const sqrt_2:SAME:=FLTD::sqrt_2.flt;
**** Approximation of 2.sqrt.
const zero:SAME := 0.0;
**** See $NUMBER.

Features
abs:SAME
**** The absolute value of self.
acos:SAME
**** The arc sine of self in the range [0.0, pi]. The trigonometric functions handle exceptional arguments in the spirit of IEEE 754-1985. So:
____+-infinity.sin,_+-infinity.cos,_+-infinity.tan_return_NaN
____x.asin_and_x.acos_with_x.abs>1_return_NaN
sinpi etc. are similar except they compute self.sinpi=(self*pi).sin avoiding range-reduction issues because their definition permits range reduction that is fast and exact for all self. The corresponding inverse functions compute asinpi(x).
acosh:SAME
**** The inverse hyperbolic cosine of self. The hyperbolic functions handle exceptional arguments in the spirit of IEEE 754-1985. So:
____sinh_and_cosh_return_+-infinity_on_overflow
____acosh_returns_a_NaN_if_its_argument_is_less_than_1.0
____atanh_returns_a_NaN_if_its_argument_has_an_absolute_value_>1.0
acospi:SAME
**** The arc sine of self*pi in the range [0.0, pi] See comment at `acos'.
asin:SAME
**** The arc sine of self in the range [-pi/2, pi/2] See comment at `acos'.
asinh:SAME
**** The inverse hyperbolic sine of self. See comment at `acosh'.
asinpi:SAME
**** The arc sine of self*pi in the range [-pi/2, pi/2] See comment at `acos'.
at_least(arg:SAME):SAME
**** Same as `self.max(arg)'
at_most(arg:SAME):SAME
**** Same as `self.min(arg)'
atan2(arg:SAME):SAME
**** The arc tangent of self divided by arg in the range [-pi/2, pi/2]. It chooses the quadrant specified by (self, arg). See comment at `acos'.
atan2pi(arg:SAME):SAME
**** The arc tangent of self*pi divided by arg in the range [-pi/2, pi/2]. It chooses the quadrant specified by (self, arg). See comment at `acos'.
atan:SAME
**** The arc tangent of self in the range [-pi/2, pi/2]. See comment at `acos'.
atanh:SAME
**** The inverse hyperbolic tangent of self. See comment at `acosh'.
atanpi:SAME
**** The arc tangent of self*pi in the range [-pi/2, pi/2]. See comment at `acos'.
bessel_j0:SAME
**** Bessel functions of the first and second kinds. y0, y1 and yn have logarithmic singularities at the origin, so they treat zero and negative arguments the way log does.
bessel_j1:SAME
**** See comment at `bessel_j0'.
bessel_jn(n:INT):SAME
**** See comment at `bessel_j0'.
bessel_y0:SAME
**** See comment at `bessel_j0'.
bessel_y1:SAME
**** See comment at `bessel_j0'.
bessel_yn(n:INT):SAME
**** See comment at `bessel_j0'.
ceiling:SAME
**** The smallest integer not less than self.
copysign(y:SAME):SAME
**** return self with the sign bit set to the same as y's sign bit.
cos:SAME
**** See comment at `acos'.
cosh:SAME
**** The hyperbolic cosine of self. See comment at `acosh'.
cospi:SAME
**** See comment at `acos'.
create(f:FLT):SAME
create(f:FLTD):SAME
create(f:INT):SAME
create(f:INTI):SAME
create (s: STR): SAME
cube:SAME
**** The cube of self.
cube_root:SAME
**** The cube root of self.
div(f:SAME):SAME
**** The quotient of self and `f'. Built-in.
erf:SAME
**** error function:
___x.erf_=_(1/sqrt(pi))*integrate(0,x,exp(-t^2)dt)
exp10:SAME
**** 10^self See comment at `exp'.
exp2:SAME
**** 2^self See comment at `exp'.
exp:SAME
**** The exponential e^self. Exponential, logarithm, power functions. All these functions handle exceptional arguments in the spirit of IEEE 754-1985. So:
____0.log_is_-infinity_with_a_division_by_zero_exception
____For_x<0,_including_-infinity,_x.log_is_a_quiet_NaN_with_an
____invalid_op_exception
____For_x=+infinity_or_a_quiet_NaN,_x.log_is_x_without_exception
____For_a_signaling_NaN,_x.log_is_a_quiet_NaN_with_
____an_invalid_op_exception
____1.log_is_zero_without_exception
For any other positive x, x.log is a normalized number with an inexact exception.
exp_minus_one:SAME
**** e^self-1.0, accurate even for tiny self. See comment at `exp'.
floor:SAME
**** The largest integer not greater than self.
flt:FLT
**** Conversion to FLT (identity operation)
fltd:FLTD
**** An FLTD version of self. Built-in.
fmt( f:STR ): STR
**** Return a nicely formatted ascii representation of the number. See the separate documentation on FMT for a full description.
gamma:SAME
**** gamma function.
get_representation(out sign:BOOL,out exp: INT,out mantissa: INT)
**** Get the data representing te flt. (endian independant)
hash:INT
**** A lousy hash function, can someone suggest better?
hypot(arg:SAME):SAME
**** sqrt(self*self+arg*arg), taking precautions against unwarranted IEEE exceptions. +-infinity.hypot(arg) is +infinity for any arg, even a NaN, and is exceptional only for a signaling NaN.
infinity:SAME
**** IEEE Infinity.
int:INT
**** INT version of self. It is an error if self is not integral. Use truncate, floor, ceiling, or round to achieve this. Built-in.
integral:BOOL
**** Another name for `is_integral'.
inti:INTI
**** Conversion to INTI.
is_bet(l,u:SAME):BOOL
**** Another name for `is_between'.
is_between(l,u:SAME):BOOL
**** True if self between l and u.
is_eq(f:SAME):BOOL
**** True if self and `f' represent the same value. Built-in.
is_eq(arg: $OB): BOOL .. Included as is_eq
is_finite:BOOL
**** returns true if zero, subnormal or normal.
is_inf:BOOL
**** returns true if infinite
is_integral:BOOL
**** Return true if self is integral.
is_lt(f:SAME):BOOL
**** True if self is less than `f'. Built-in.
is_nan:BOOL
**** returns true if NaN. See comment at "is_nil".
is_nil:BOOL
is_normal:BOOL
**** returns true if normal
is_subnormal:BOOL
**** returns true if subnormal
is_within(tolerance,val:SAME):BOOL
is_zero:BOOL
**** returns true is zero
log10:SAME
**** The logarithm base ten of self. See comment at `exp'.
log2:SAME
**** The logarithm base two of self. See comment at `exp'.
log:SAME
**** The natural logarithm of self. See comment at `exp'.
log_gamma:SAME
**** log gamma function. x.ln_gamma=x.gamma.abs.log
max(arg:SAME):SAME
**** The larger of self and arg. Caution: may not work as one expects if an argument is NaN.
max_normal:SAME
**** The largest normalized positive number.
max_subnormal:SAME
**** The largest subnormal positive number.
maxval:SAME
**** Maximal value; see $NUMBER.
min(arg:SAME):SAME
**** The smaller of self and arg. Caution: may not work as one expects if an argument is NaN.
min_normal:SAME
**** The smallest normalized positive number.
min_subnormal:SAME
**** The smallest subnormal positive number.
minus(f:SAME):SAME
**** The difference between self and `f'. Built-in.
minval:SAME
**** Minimal value; see $NUMBER.
mod(y:SAME):SAME
**** See comment at `remainder'.
negate:SAME
**** The negation of self. Same as zero minus self, except that IEEE does funny things for the sign bit and different rounding modes.
nextdown:SAME
**** return previous representable number from self.
nextup:SAME
**** return next representable number from self.
nil:SAME
**** The value to be used to represent no element in sets.
one_minus_erf:SAME
**** 1.0-self.erf, but computed in a way to avoid cancellation for large self.
plus(f:SAME):SAME
**** The sum of self and `f'. Built-in.
plus_one_log:SAME
**** (self+1).log, accurate even for tiny self. See comment at `exp'.
pow(arg:SAME):SAME
**** self raised to the arg'th power. x.pow(0.0)=1.0 for all x. See comment at `exp'.
quiet_NaN(sig:INT):SAME
**** IEEE quiet NaN. `sig' is the significand (presently unused).
remainder(y:SAME):SAME
**** x.remainder(y) and x.mod(y) return a remainder of x with respect to y; that is, the result r is one of the numbers that differ from x by an integral multiple of y. Thus (x-r)/y is an integral value, even though it might exceed INT::maxint if it were explicitly computed as an INT. Both functions return one of the two such r smallest in magnitude. remainder(x,y) is the operation specified in ANSI/IEEE Std 754-1985; the result of x.mod(y) may differ from remainder's result by +-y. The magnitude of remainder's result can not exceed half that of y; its sign might not agree with either x or y. The magnitude of mod's result is less than that of y; its sign agrees with that of x. Neither function will raise an exception as long as both arguments are normal or subnormal. x.remainder(0), x.mod(0), infinity.remainder(y), and infinity.mod(y) are invalid operations that produce a NaN.
round:SAME
**** The closest integer to self.
scale_by(n:INT):SAME
**** return x*2.pow(n) computed by exponent manipulation rather than by actually performing an exponentiation or a multiplication.

____1_<=_x.abs.scale_by(-x.unbiased_exponent)_<_2_

for every x except 0, infinity, and NaN.
sign:SAME
**** -1.0, 0.0, or 1.0, depending whether the sign of self is negative, zero, or positive.
signaling_NaN(sig:INT):SAME
**** IEEE signalling NaN. `sig' is the significand (presently unused).
signbit_set:BOOL
**** returns true if sign bit of self is set
signum:SAME
**** Another name for `sign'.
sin:SAME
**** See comment at `acos'.
sincos(out s:FLT,out c:FLT)
**** Simultaneous computation of self.sin and self.cos. This is faster than independently computing them. See comment at `acos'.
sincospi(out a:FLT,out b:FLT)
**** Simultaneous computation of self.sinpi and self.cospi. Faster than independently computing them. See comment at `acos'.
sinh:SAME
**** The hyperbolic sine of self. See comment at `acosh'.
sinpi:SAME
**** See comment at `acos'.
sqrt:SAME
**** The square root of self.
square:SAME
**** The square of self.
str(prec:INT):STR
**** A string version of self with arg digits of precision.
str:STR
**** A string version of self. The other str methods work this way too (they used to use a shared buffer.) if ((void(fbuf)) or (fbuf.size < 30)) then fbuf := #FSTR(30) end;
str_in(arg:FSTR):FSTR
str_in(arg: FSTR,
tan:SAME
**** See comment at `acos'.
tanh:SAME
**** The hyperbolic tangent of self. See comment at `acosh'.
tanpi:SAME
**** See comment at `acos'.
times(f:SAME):SAME
**** The signed product of self and `f'. Built-in.
truncate:SAME
**** The nearest integer toward zero. Built-in.
unbiased_exponent:INT
**** return unbiased exponent of self as an INT; for zero this is INT::maxint.negate, for an infinite it is INT::maxint. If subnormal, normalization occurs first.

Iters
product!(i:SAME):SAME
**** Yields the product of all previous values of `i'.
sum!(i:SAME):SAME
**** Yields the sum of all previous values of `i'.


Private

store_into(s:FSTR):INT
**** Store the acsii representation into s. Built-in.
store_into_prec(p:INT,s:FSTR):INT
**** Store the acsii representation into s with precision p. Built-in.

The Sather Home Page