eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'QuadFloat':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: QuadFloat


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--ArithmeticValue
         |
         +--Number
            |
            +--LimitedPrecisionReal
               |
               +--AbstractIEEEFloat
                  |
                  +--QuadFloat

Package:
stx:libbasic2
Category:
Magnitude-Numbers
Version:
rev: 1.148 date: 2023/09/12 12:59:09
user: cg
file: QuadFloat.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


Notice:
    Unfinished, ongoing work
    Basic arithmetic should work, but rounding is not working correctly,
    this affects some of the series approximations (i.e. trigonometric).
    Therefore for the time being:
        Please only use them if you need to represent 256bit floats to be exchanged
        with the external world (i.e. to get the bit representation).

        If you need more precision than double IEEE precision, wither use QDoubles;
        which are faster and provide almost the same precision as OctaFloats,
        or use LargeFloats which provide any precision.

QuadFloats represent rational numbers with limited precision
and are mapped to IEEE quadruple precision format (128bit),
also called 'binary128'.

If the underlying cpu supports them natively, the machine format (long double) is
used. Otherwise, a software emulation is done, which is much slower.
Thus only use them, if you really need the additional precision;
if not, use Float (which are doubles) or LongFloats which usually have IEEE extended precision (80bit).

QuadFloats give you definite 128 bit quadruple floats,
thus, code using quadFloats is guaranteed to be portable from one architecture to another.

Representation:
        128bit quadruple IEEE floats (16bytes);
        112 bit mantissa,
        16 bit exponent,
        34 decimal digits (approx.)

On Sparc CPUs, this is a native supported type (long double) and fast;
on x86 CPUs, this is emulated and slow.

Mixed mode arithmetic:
    quadFloat op anyFloat    -> quadFloat
    anyFloat op quadFloat    -> quadFloat

Range and precision of storage formats: see LimitedPrecisionReal >> documentation

[aliases:]
    Float128

copyright

COPYRIGHT (c) 2018 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

class initialization
o  initialize
print up to 20 valid digits

coercing & converting
o  coerce: aNumber
convert the argument aNumber into an instance of the receiver's class and return it.

o  generality
return the generality value - see ArithmeticValue>>retry:coercing:

constants
o  NaN
return a quadFloat which represents not-a-Number (i.e. an invalid number)

Usage example(s):

     NaN := nil.
     self NaN

o  e
return the constant e as quadFloat

Usage example(s):

eDigits has enough digits for 128bit IEEE quads

Usage example(s):

do not use as a literal constant here - we cannot depend on the underlying C-compiler here...

Usage example(s):

Modified (comment): / 27-10-2021 / 10:09:42 / cg

o  halfPi
return the constant pi/2 as quadFloat

o  infinity
return a quadFloat which represents +INF

Usage example(s):

     PositiveInfinity := nil.
     self infinity

o  ln10
return the constant natural logarithm log(10) as a quadFloat

Usage example(s):

ln10Digits has enough digits for 128bit IEEE quads

Usage example(s):

     Ln10 := nil.
     QuadFloat ln10

o  ln2
return the constant ln(2) as quadFloat

Usage example(s):

ln2Digits has enough digits for 128bit IEEE quads

Usage example(s):

     Ln2 := nil.
     QuadFloat ln2

o  negativeInfinity
return a quadFloat which represents -INF

Usage example(s):

     NegativeInfinity := nil.
     self negativeInfinity

o  phi
return the constant phi as quadFloat

Usage example(s):

phiDigits has enough digits for 128bit IEEE quads

o  pi
return the constant pi as quadFloat

Usage example(s):

piDigits has enough digits for 128bit IEEE quads

Usage example(s):

do not use as a literal constant here - we cannot depend on the underlying C-compiler here...

Usage example(s):

     Pi := nil.
     self pi

o  sqrt2
return the constant sqrt(2) as QuadFloat

Usage example(s):

sqrt2Digits has enough digits for 128bit IEEE quads

Usage example(s):

     LongFloat sqrt2 -> 1.414213562373095049
     QuadFloat sqrt2 -> 1.41421356237309225889475789602312

o  sqrt3
return the constant sqrt(3) as QuadFloat

Usage example(s):

sqrt3Digits has enough digits for 128bit IEEE quads

Usage example(s):

     LongFloat sqrt3 -> 1.732050807568877294
     QuadFloat sqrt3 -> 1.7320508075688749727305550199462

o  two
return the constant 2.0 as QuadFloat

o  unity
return the neutral element for multiplication (1.0) as QuadFloat

Usage example(s):

     QuadFloatOne := nil.
     self unity

o  zero
return the neutral element for addition (0.0) as QuadFloat

Usage example(s):

     QuadFloatZero := nil.
     self zero

error reportng
o  errorUnsupported
you may proceed from this error, to get a long float number result
(of course, with less than expected precision)

instance creation
o  basicNew
return a new quadFloat - here we return 0.0
- QuadFloats are usually NOT created this way ...
Its implemented here to allow things like binary store & load
of quadFloats.
(but it is not a good idea to store the bits of a float - the reader might have a
totally different representation - so floats should be
binary stored in a device independent format).

o  basicNew: size
(comment from inherited method)
return an instance of myself with anInteger indexed variables.
If the receiver-class has no indexed instvars, this is only allowed
if the argument, anInteger is zero.
** Do not redefine this method in any class **

o  fromFloat: aFloat
return a new quadFloat, given a float value

Usage example(s):

     QuadFloat fromFloat:0.0
     QuadFloat fromFloat:1.0
     QuadFloat fromFloat:123.0
     QuadFloat fromFloat:(Float NaN)
     QuadFloat fromFloat:(Float infinity)
     QuadFloat fromFloat:(Float negativeInfinity)
     QuadFloat fromFloat:(Float fmin)
     QuadFloat fromFloat:(Float fmax)
     QuadFloat fromFloat:(Float fmaxDenormalized) 2.22507386e-308
     QuadFloat fromFloat:(Float fminDenormalized) 4.94065645841247e-324

     123.0 asQuadFloat
     123 asQuadFloat

o  fromInteger: anInteger
return a new quadFloat, given an integer value

Usage example(s):

     QuadFloat fromInteger:123
     123 asQuadFloat
     1 asQuadFloat
     0x3FFFFFFFFFFFFFFF asQuadFloat
     -0x3FFFFFFFFFFFFFFF asQuadFloat

o  fromLongFloat: aFloat
return a new quadFloat, given a long float value

Usage example(s):

     QuadFloat fromLongFloat:123.0 asLongFloat

o  fromShortFloat: aShortFloat
return a new quadFloat, given a float value

Usage example(s):

     QuadFloat fromShortFloat:123.0 asShortFloat

o  new: size
(comment from inherited method)
catch this message - not allowed for floats/doubles

queries
o  defaultExponentSizeForByteSize: nBytes
(comment from inherited method)
self defaultExponentSizeForByteSize:2 5
self defaultExponentSizeForByteSize:4 8
self defaultExponentSizeForByteSize:5 8
self defaultExponentSizeForByteSize:8 11
self defaultExponentSizeForByteSize:10 15
self defaultExponentSizeForByteSize:16 15
self defaultExponentSizeForByteSize:32 19
self defaultExponentSizeForByteSize:64 32

o  defaultPrintFormat
'.20' by default, I will print up to 20 digits

o  defaultPrintPrecision
the default number of digits when printing

o  defaultPrintfPrecision
the default number of digits when printing with printf's %f format

o  epsilon
return the maximum relative spacing of instances of mySelf
(i.e. the value-delta of the least significant bit)
according to ISO C standard;
Ada, C, C++ and Python language constants;
Mathematica, MATLAB and Octave; and various textbooks
see https://en.wikipedia.org/wiki/Machine_epsilon

Usage example(s):

     self epsilon
     (QuadFloat coerce:self radix) raisedToInteger:(QuadFloat precision - 1) negated.

o  exponentCharacter
return the character used to print between mantissa an exponent.
Also used by the scanner when reading numbers.

o  isSupported

o  numBitsInExponent
answer the number of bits in the exponent.
This is an IEEE 128bit quadfloat, where 15 bits are available in the exponent:
seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...

Usage example(s):

     1.0 class numBitsInExponent -> 11
     1.0 asShortFloat class numBitsInExponent -> 8
     1.0 asLongFloat class numBitsInExponent -> 15
     1.0 asQuadFloat class numBitsInExponent -> 15

     QuadFloat numBitsInExponent -> 15
     QuadFloat eBias             -> 16383

o  numBitsInMantissa
answer the number of bits in the mantissa (the significant)
This is an 128bit quadfloat, where 112 bits are available in the mantissa
The hidden bit is not counted here
seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...

Usage example(s):

     1.0 class numBitsInMantissa
     1.0 asShortFloat class numBitsInMantissa
     1.0 asLongFloat class numBitsInMantissa
     1.0 asQuadFloat class numBitsInMantissa

o  radix
answer the radix of a QuadFloat's exponent
This is an IEEE float, which is represented as binary


Instance protocol:

arithmetic
o  * aNumber
return the product of the receiver and the argument.

Usage example(s):

     1.0 asQuadFloat * 1.0 asQuadFloat
     1.0 asQuadFloat * 2.0 asQuadFloat
     1.0 asQuadFloat * 2.0 asQuadFloat negated
     2.0 asQuadFloat * 2.0 asQuadFloat
     2.0 asQuadFloat * 0.5 asQuadFloat
     QuadFloat fmin * 2.0 asQuadFloat
     QuadFloat fminDenormalized * 2.0 asQuadFloat

o  + aNumber
return the sum of the receiver and the argument, aNumber

Usage example(s):

     1.0 asQuadFloat + 1.0 asQuadFloat
     1.0 asQuadFloat + 2.0 asQuadFloat
     1.0 asQuadFloat + 2.0 asQuadFloat negated
     2.0 asQuadFloat + 2.0 asQuadFloat
     2.0 asQuadFloat + 0.5 asQuadFloat
     QuadFloat fmin + QuadFloat fmin
     QuadFloat fminDenormalized + QuadFloat fminDenormalized

o  - aNumber
return the difference of the receiver and the argument, aNumber

Usage example(s):

     1.0 asQuadFloat - 1.0 asQuadFloat
     1.0 asQuadFloat - 2.0 asQuadFloat
     2.0 asQuadFloat - 1.0 asQuadFloat
     2.0 asQuadFloat - 2.0 asQuadFloat
     3.0 asQuadFloat - 2.0 asQuadFloat
     2.0 asQuadFloat - 0.5 asQuadFloat
     QuadFloat fmin - QuadFloat fmin
     QuadFloat fminDenormalized - QuadFloat fminDenormalized

o  / aNumber
return the quotient of the receiver and the argument, aNumber

o  abs
return the absolute value of the receiver
reimplemented here for speed

Usage example(s):

^ super abs

Usage example(s):

     1.0 asQuadFloat abs         -> 1.0
     1.0 asQuadFloat negated abs -> 1.0
     -1.0 asQuadFloat abs        -> 1.0

o  negated
return the receiver negated

Usage example(s):

     1.0 asQuadFloat
     1.0 asQuadFloat negated
     -1.0 asQuadFloat negated

o  rem: aNumber
return the floating point remainder of the receiver and the argument, aNumber

Usage example(s):

     20 rem:3                             2
     20.0 rem:3.0                         2.0
     20.0 asQuadFloat rem:3.0 asQuadFloat 2.0
     20.0 asQDouble rem:3.0 asQDouble     2.0

coercing & converting
o  asFloat
return a Float (i.e. an IEEE double) with same value as the receiver.
Does NOT raise an error if the receiver exceeds the float range or is non-finite.
Returns infinity if the receiver exceeds the float range.

Usage example(s):

     1.0 asQuadFloat asFloat -> 1.0
     1Q4000 asFloat          -> inf

o  asQuadFloat
1.0 asQuadFloat asQuadFloat

o  coerce: aNumber
convert the argument aNumber into an instance of the receiver's class and return it.

Usage example(s):

     QuadFloat coerce:2.5
     QuadFloat coerce:25

o  generality
return the generality value - see ArithmeticValue>>retry:coercing:

comparing
o  < aNumber
return true, if the argument is greater

Usage example(s):

     1.0 asQuadFloat < 1.0 asQuadFloat
     1.0 asQuadFloat < 2.0 asQuadFloat
     1.0 asQuadFloat < 2.0 asQuadFloat negated
     2.0 asQuadFloat < 2.1 asQuadFloat
     2.0 asQuadFloat < 0.5 asQuadFloat

o  <= aNumber
return true, if the argument is greater or equal

Usage example(s):

     1.0 asQuadFloat <= 1.0 asQuadFloat
     1.0 asQuadFloat <= 0.5 asQuadFloat
     1.0 asQuadFloat <= 2.0 asQuadFloat
     1.0 asQuadFloat <= 2.0 asQuadFloat negated
     1.0 asQuadFloat <= 1.0 asQuadFloat negated
     1.0 asQuadFloat <= 0.5 asQuadFloat negated
     1.0 asQuadFloat negated <= 2.0 asQuadFloat
     1.0 asQuadFloat negated <= 1.0 asQuadFloat
     1.0 asQuadFloat negated <= 0.5 asQuadFloat
     1.0 asQuadFloat negated <= 2.0 asQuadFloat negated
     1.0 asQuadFloat negated <= 1.0 asQuadFloat negated
     1.0 asQuadFloat negated <= 0.5 asQuadFloat negated
     2.0 asQuadFloat <= 2.1 asQuadFloat
     2.0 asQuadFloat <= 0.5 asQuadFloat

o  = something
return true, if the argument represents the same numeric value
as the receiver, false otherwise

Usage example(s):

     1.0 asQuadFloat = 1.0 asQuadFloat
     1.0 asQuadFloat = 2.0 asQuadFloat
     1.0 asQuadFloat = 2.0 asQuadFloat negated
     1.0 asQuadFloat = 1.0 asQuadFloat negated

o  > aNumber
return true, if the receiver is greater

o  >= aNumber
return true, if the receiver is greater or equal

Usage example(s):

     1.0 asQuadFloat >= 1.0 asQuadFloat
     1.0 asQuadFloat >= 2.0 asQuadFloat
     1.0 asQuadFloat >= 2.0 asQuadFloat negated
     2.0 asQuadFloat >= 2.1 asQuadFloat
     2.0 asQuadFloat >= 0.5 asQuadFloat

o  hash
return a number for hashing; redefined, since floats compare
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same
as 3 hash.

Usage example(s):

     1.2345 hash
     1.2345 asShortFloat hash
     1.2345 asLongFloat hash
     1.2345 asQuadFloat hash

     1.0 hash
     1.0 asShortFloat hash
     1.0 asLongFloat hash
     1.0 asQuadFloat hash

     0.5 asShortFloat hash
     0.5 asShortFloat hash
     0.5 asLongFloat hash
     0.5 asQuadFloat hash

     0.25 asShortFloat hash
     0.25 asShortFloat hash
     0.25 asLongFloat hash
     0.25 asQuadFloat hash

double dispatching
o  lessFromQuadFloat: aQuadFloat
sent when aQuadFloat does not know how to compare against the receiver, self.
No longer used: all compare operators are implemented here.

Usage example(s):

     1 asQuadFloat lessFromQuadFloat:0 asQuadFloat
     1 asQuadFloat lessFromQuadFloat:2 asQuadFloat
     1 asQuadFloat lessFromQuadFloat:1 asQuadFloat

o  productFromQuadFloat: aQuadFloat
sent when aQuadFloat does not know how to multiply the receiver, self

o  quotientFromQuadFloat: aQuadFloat
sent when aQuadFloat does not know how to be divided by the receiver, self

o  sumFromQuadFloat: aQuadFloat
sent when aQuadFloat does not know how to add the receiver, self

mathematical functions
o  _arcTan
<<END
|x y z sign _T3P8 _TP8 _PIO2L _PIO4L _P _Q|

_T3P8 := 2.414213562373095048801688724209698078569672Q.
_TP8 := 0.414213562373095048801688724209698078569672Q.
_PIO2L := 1.570796326794896619231321691639751442098585Q. "/ pi/2
_PIO4L := 0.7853981633974483096156608458198757210492923Q. "/ pi/4

_P := #(
-6.635810778635296712545011270011752799963Q-4
-8.768423468036849091777415076702113400070Q-1
-2.548067867495502632615671450650071218995Q1
-2.497759878476618348858065206895055957104Q2
-1.148164399808514330375280133523543970854Q3
-2.792272753241044941703278827346430350236Q3
-3.696264445691821235400930243493001671932Q3
-2.514829758941713674909996882101723647996Q3
-6.880597774405940432145577545328795037141Q2
).

_Q := #(
"/ 1.000000000000000000000000000000000000000Q0
3.566239794444800849656497338030115886153Q1
4.308348370818927353321556740027020068897Q2
2.494680540950601626662048893678584497900Q3
7.928572347062145288093560392463784743935Q3
1.458510242529987155225086911411015961174Q4
1.547394317752562611786521896296215170819Q4
8.782996876218210302516194604424986107121Q3
2.064179332321782129643673263598686441900Q3
).

"/ make argument positive and save the sign
x := self.
(sign := self signBit) == 1 ifTrue:[
x := x negated.
].
"/ range reduction
x > _T3P8 ifTrue:[
y := _PIO2L.
x := ( 1.0Q / x ) negated.
] ifFalse:[
x > _TP8 ifTrue:[
y := _PIO4L.
x := (x - 1.0Q) / (x + 1.0Q).
] ifFalse:[
y := 0.0Q.
].
].
"/ rational form in x**2 */
z := x squared.
y := y + (( (self polevll:{ z . _P . 8 }) / (self p1evll:{ z . _Q . 8 }) ) * z * x + x).
sign == 1 ifTrue:[
y := y negated
].
^ y

"
1.0 arcTan 0.785398163397448
1.0Q _arcTan 0.78539816339744843718162064439161164
1.0Q arcTan 0.78539816339744133175426300314281141

LargeFloat pi / 4 0.78539816339744830961566084581987572104929234984377645524374
1.0QO arcTan 0.785398163397448309615660845819875721049292349843776455243736148076954116
1.0QL arcTan 0.78539816295210311369632527881822427650433569045226495020673
0.7853981633974483096156608458198757210492923498437764552437361480769541015715522496570087063355292669955370216283205766617734611...
"
END>>

o  cbrt
return the cubic root of myself.

o  exp
return e raised to the power of the receiver

o  ln
return the natural logarithm of the receiver.

o  log
return log base 10 of the receiver.
Alias for log:10.

o  log2
return logarithm dualis of the receiver.

o  p1evll: args
Polynomial evaluator:

o  polevll: args
Polynomial evaluator:

o  sqrt
return the square root of myself.
Raises an exception, if the receiver is less than zero.

Usage example(s):

     4.0 asQuadFloat sqrt
     0.5 asQuadFloat sqrt

printing
o  printOn: aStream
self commonPrintOn:aStream

private accessing
o  basicAt: index
return an internal byte of the float.
The value returned here depends on byte order, float representation etc.
Therefore, this method should be used strictly private.

Notice:
the need to redefine this method here is due to the
inability of many machines to store floats in non-double aligned memory.
Therefore, on some machines, the first 4 bytes of a float are left unused,
and the actual float is stored at index 5 .. 12.
To hide this at one place, this method knows about that, and returns
values as if this filler wasnt present.

o  basicAt: index put: value
set an internal byte of the float.
The value to be stored here depends on byte order, float representation etc.
Therefore, this method should be used strictly private.

Notice:
the need to redefine this method here is due to the
inability of many machines to store floats in non-double aligned memory.
Therefore, on some machines, the first 4 bytes of a float are left unused,
and the actual float is stored at index 5 .. 12.
To hide this at one place, this method knows about that, and returns
values as if this filler wasnt present.

o  basicSize
return the size in bytes of the float.

Notice:
the need to redefine this method here is due to the
inability of many machines to store floats in non-double aligned memory.
Therefore, on some machines, the first 4 bytes of a float are left unused,
and the actual float is stored at index 5 .. 12.
To hide this at one place, this method knows about that, and returns
values as if this filler wasn't present.

o  exponentSize: numBitsInExponent
I have a hard-coded exponentSize;
verify that instances are created correctly here

o  setFraction: normalizedFractionArg biasedExponent: biasedExponentArg signBit: signBit
@Commented by exept MBP at: 2021-10-21 14:38 Reason:

Usage example(s):

     (self size:128 exponentSize:15) setFraction:0 biasedExponent:(QuadFloat eBias) signBit:0             -> 1.0
     (self size:128 exponentSize:15) setFraction:0 biasedExponent:(QuadFloat eBias+1) signBit:0           -> 2.0
     (self size:128 exponentSize:15) setFraction:0 biasedExponent:(QuadFloat eBias+QuadFloat emax) signBit:0  -> 5.94865747e4931
     QuadFloat NaN
     0.0 asQuadFloat
     (self size:128 exponentSize:15) setFraction:0 biasedExponent:0 signBit:0                             -> 0.0

o  xxsetFraction: normalizedFractionArg biasedExponent: biasedExponentArg signBit: signBit
(self size:128 exponentSize:15) xsetFraction:0 biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:0 biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:1 biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<32) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<64) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<96) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<104) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<111) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
(self size:128 exponentSize:15) setFraction:(1<<32) biasedExponent:QuadFloat eBias signBit:0 -> 1.0
1.0 asQuadFloat

queries
o  eBias
Answer the exponent's bias;
that is the offset of the zero exponent when stored

Usage example(s):

     1.0 asQuadFloat eBias  -> 16383
     1.0 eBias              -> 1023

o  emax
The largest exponent value allowed by instances like me.
This is also implemented on the instance side,
because of IEEEFloat, which has instance-specific representation.

Usage example(s):

     Float emax       -> 1023
     ShortFloat emax  -> 127
     LongFloat emax   -> 16383
     QuadFloat emax   -> 16383
     OctaFloat emax   -> 262143
     QDouble emax     -> 1023

o  emin
The smallest exponent value allowed by (normalized) instances of this class.
This is also implemented on the instance side,
because of IEEEFloat, which has instance-specific representation.

Usage example(s):

     Float emin
     QuadFloat emin
     QuadFloat emax
     OctaFloat emin
     OctaFloat emax

o  exponent
extract a normalized float's (unbiased) exponent.
This assumes that the mantissa is normalized to
0.5 .. 1.0 and the float's value is:
mantissa * 2^exponent

Usage example(s):

     1.0 exponent                 1
     1.0 asQuadFloat exponent     1
     2.0 exponent
     2.0 asQuadFloat exponent     2
     3.0 exponent
     3.0 asQuadFloat exponent     2
     4.0 exponent
     4.0 asQuadFloat exponent     3
     0.5 exponent
     0.5 asQuadFloat exponent     0
     0.4 exponent
     0.4 asQuadFloat exponent     -1
     0.25 exponent
     0.25 asQuadFloat exponent    -1
     0.2 exponent
     0.2 asQuadFloat exponent     -2
     0.00000011111 exponent               -23
     0.00000011111 asQuadFloat exponent   -23
     0.0 exponent                 0
     0.0 asQuadFloat exponent     0
     0.0 nextFloat exponent       -1073
     0.0 asQuadFloat nextFloat exponent  -16493

     Float fmin exponent                -1021
     Float fmin asQuadFloat exponent    -1021
     (Float fmin / 2) exponent          -1022
     (Float fmin / 2) asQuadFloat exponent   -1022
     QuadFloat fmin exponent            -16381
     (QuadFloat fmin / 2) exponent      -16382
     (QuadFloat fmin / 4) exponent      -16383
     (QuadFloat fminDenormalized) exponent -16493

     1e1000 exponent -> error (INF)
     1e1000 asQuadFloat exponent -> error (INF)
     QuadFloat NaN exponent -> error
     QuadFloat infinity exponent -> error

o  exponentBits
return the bits of my exponent.
These might be biased.

Usage example(s):

     0.0 asQuadFloat exponentBits  -> 0
     QuadFloat fmin exponentBits   -> 1
     QuadFloat fmaxDenormalized exponentBits -> 0
     1.0 asQuadFloat exponentBits  -> 16383
     -1.0 asQuadFloat exponentBits -> 16383
     10.0 asQuadFloat exponentBits  -> 16386
     0.125 asQuadFloat exponentBits -> 16380
     0.1 asQuadFloat exponentBits   -> 16379
     QuadFloat NaN exponentBits      -> 32767
     QuadFloat infinity exponentBits -> 32767

o  isFinite
return true, if the receiver is a finite float (not NaN and not +/-INF)

Usage example(s):

     1.0 isFinite                           true
     self NaN isFinite                      false
     self infinity isFinite                 false
     self negativeInfinity isFinite         false
     (0.0 uncheckedDivide: 0.0) isFinite    false
     (1.0 uncheckedDivide: 0.0) isFinite    false

o  isInfinite
return true, if the receiver is an infinite float (+Inf or -Inf).

Usage example(s):

     1.0 asQuadFloat isInfinite                                     false
     QuadFloat NaN isInfinite                                       false
     QuadFloat infinity isInfinite                                  true
     QuadFloat negativeInfinity isInfinite                          true
     (0.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isInfinite  false
     (1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isInfinite  true

o  isNaN
return true, if the receiver is an invalid float (NaN - not a number).
These are usually not created by ST/X float operations (they raise an exception);
however, inline C-code or proceeded exceptions or reading from a stream
could produce them.

Usage example(s):

     1.0 asQuadFloat isNaN                                     false
     QuadFloat NaN isNaN                                       true
     QuadFloat infinity isNaN                                  false
     QuadFloat negativeInfinity isNaN                          false
     (0.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isNaN  true
     (1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isNaN  false

o  isNegativeInfinity
return true, if the receiver is a negative infinite float (-Inf).

Usage example(s):

     1.0 asQuadFloat isNegativeInfinity                                     false
     QuadFloat NaN isNegativeInfinity                                       false
     QuadFloat infinity isNegativeInfinity                                  false
     QuadFloat negativeInfinity isNegativeInfinity                          true
     (0.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isNegativeInfinity  false
     (1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isNegativeInfinity  false
     (-1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isNegativeInfinity true

o  isPositiveInfinity
return true, if the receiver is a positive infinite float (+Inf).

Usage example(s):

     1.0 asQuadFloat isPositiveInfinity                                     false
     QuadFloat NaN isPositiveInfinity                                       false
     QuadFloat infinity isPositiveInfinity                                  true
     QuadFloat negativeInfinity isPositiveInfinity                          false
     (0.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isPositiveInfinity  false
     (1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isPositiveInfinity  true
     (-1.0 asQuadFloat uncheckedDivide: 0.0 asQuadFloat) isPositiveInfinity false

o  isZero
return true, if the receiver is zero

Usage example(s):

     0 asQuadFloat isZero           -> true
     0 asQuadFloat negated isZero   -> true
     1 asQuadFloat isZero           -> false
     QuadFloat NaN isZero           -> false
     QuadFloat infinity isZero      -> false

o  mantissa
extract a normalized float's mantissa (as QuadFloat).
That is a float of the same type as the receiver,
such that:
(f mantissa) * (2 ^ f exponent) = f
The returned value depends on the float-representation of
the underlying machine and is therefore highly unportable.
This is not for general use.
This assumes that the mantissa is normalized to 0.5 .. 1.0

Usage example(s):

     1.0 exponent                -> 1
     1.0 asQuadFloat exponent    -> 1
     1.0 mantissa                -> 0.5
     1.0 asQuadFloat mantissa    -> 0.50000

     10.0 mantissa               -> 0.625
     10.0 asQuadFloat mantissa   -> 0.625

     QuadFloat eBias             -> 0.5
     QuadFloat fmin mantissa     -> 0.5
     QuadFloat fminDenormalized mantissa 0.50000
     QuadFloat fmaxDenormalized mantissa 1.00000

     16 asQuadFloat exponent      -> 5
     16 asQuadFloat mantissa      -> 0.5

     0.0 mantissa                 -> 0.0
     0.0 asQuadFloat mantissa     -> 0.0

     0.25 exponent                -1
     0.25 asQuadFloat exponent    -1
     0.25 mantissa                0.5
     0.25 asQuadFloat mantissa    0.50000

     0.00000011111 exponent       -23
     0.00000011111 mantissa       0.93205823488 timesTwoPower:-23 => 1.1111e-07

     1e1000 mantissa
     1Q1000 exponent              3322
     1Q1000 mantissa              0.951381Q timesTwoPower:3322    => 1.0e+1000
     QuadFloat NaN exponentBits

o  mantissaBits
return the bits of my mantissa (excl. any hidden bit).
I.e. this returns the normalized mantissaBits as an integer

Usage example(s):

     1.0 mantissaBits             => 0
     1.0 asQuadFloat mantissaBits => 0
     Float fmax mantissaBits      => 4503599627370495
     QuadFloat fmax mantissaBits  => 5192296858534827628530496329220095
     QuadFloat fmin mantissaBits  => 0
     QuadFloat fminDenormalized mantissaBits  => 1
     QuadFloat fmaxDenormalized mantissaBits  => 5192296858534827628530496329220095

o  mantissaWithHiddenBits
(comment from inherited method)
return the bits of my mantissa (incl. any hidden bit).
I.e. this returns the denormalized mantissaBits.
My bytes are stored LSB first.

o  negative
return true, if the receiver is negative

Usage example(s):

     0 asQuadFloat negative              -> false
     1 asQuadFloat negative              -> false
     -1 asQuadFloat negative             -> true
     QuadFloat NaN negative              -> false
     QuadFloat NaN negated negative      -> true
     QuadFloat infinity negative         -> false
     QuadFloat infinity negated negative -> true

o  numBitsInExponent
answer the number of bits in the exponent.
This is an IEEE 128bit quadfloat, where 15 bits are available in the exponent:
seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...

Usage example(s):

     1.0 class numBitsInExponent -> 11
     1.0 asShortFloat class numBitsInExponent -> 8
     1.0 asLongFloat class numBitsInExponent -> 15
     1.0 asQuadFloat class numBitsInExponent -> 15

     QuadFloat numBitsInExponent -> 15
     QuadFloat eBias             -> 16383

o  numBitsInMantissa
answer the number of bits in the mantissa (the significant)
This is an 128bit quadfloat, where 112 bits are available in the mantissa
The hidden bit is not counted here
seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...

o  positive
return true, if the receiver is not negative (i.e. self >= 0)

Usage example(s):

     0 asQuadFloat positive              -> true
     1 asQuadFloat positive              -> true
     -1 asQuadFloat positive             -> false
     QuadFloat NaN positive              -> true
     QuadFloat NaN negated positive      -> false
     QuadFloat infinity positive         -> true
     QuadFloat infinity negated positive -> false

testing
o  isFloat128
Answer whether the receiver is a 128bit quadruple precision float.
Always true here.

o  isQuadFloat
return true, if the receiver is some kind of quad floating point number (iee quad precision)

trigonometric
o  arcCos
return the arccosine of the receiver (as radians).
Raises an exception, if the receiver is not in -1..1

o  arcSin
return the arcsine of the receiver (as radians).
Raises an exception, if the receiver is not in -1..1

o  arcTan
return the arctangent of the receiver (as radians)

o  cos
return the cosine of the receiver (interpreted as radians)

o  sin
return the sine of the receiver (interpreted as radians)

Usage example(s):

     2 sin               0.909297426825682
     2 asQuadFloat sin   0.909297427

o  tan
return the tangent of the receiver (interpreted as radians)

trigonometric - hyperbolic
o  arCosh
return the hyperbolic area cosine of the receiver.

o  arSinh
return the hyperbolic area sine of the receiver.

o  arTanh
return the hyperbolic area tangent of the receiver.

o  cosh
return the hyperbolic cosine of the receiver (interpreted as radians)

o  sinh
return the hyperbolic sine of the receiver (interpreted as radians)

o  tanh
return the hyperbolic tangent of the receiver (interpreted as radians)

truncation & rounding
o  ceiling
return the smallest integer which is greater or equal to the receiver.

Usage example(s):

     0.5 asQuadFloat ceiling
     0.5 asQuadFloat ceilingAsFloat
     -0.5 asQuadFloat ceiling
     -0.5 asQuadFloat ceilingAsFloat

o  ceilingAsFloat
return the smallest integer-valued float greater or equal to the receiver.
This is much like #ceiling, but avoids a (possibly expensive) conversion
of the result to an integer.
It may be useful, if the result is to be further used in another float-operation.

o  floor
return the integer nearest the receiver towards negative infinity.

Usage example(s):

     0.5 asQuadFloat floor
     0.5 asQuadFloat floorAsFloat
     -0.5 asQuadFloat floor
     -0.5 asQuadFloat floorAsFloat

o  floorAsFloat
return the integer nearest the receiver towards negative infinity as a float.
This is much like #floor, but avoids a (possibly expensive) conversion
of the result to an integer.
It may be useful, if the result is to be further used in another float-operation.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 08:36:55 GMT