eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HalfFloat':

Home

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

Class: HalfFloat


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--ArithmeticValue
         |
         +--Number
            |
            +--LimitedPrecisionReal
               |
               +--HalfFloat

Package:
stx:libbasic2
Category:
Magnitude-Numbers
Version:
rev: 1.13 date: 2021/11/23 16:25:12
user: cg
file: HalfFloat.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


HalfFloats represent rational numbers with very very limited precision.

There are no instances of it to be created - halfFloats are only possibly stored
inside instancs of HalfFloatArray, which are presented as floats or shortFloats when accessd.
However, this class is provided for queries about precision, bits in mantissa etc.

Representation (IEEE s10e5 binary16):
        16bit single precision IEEE floats
        10 bit fraction + 1 hidden bit, providing a precision of 11bits,
        5 bit exponent,
        3 decimal digits (approx.)

Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation

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:

constants & defaults
o  NaN
(comment from inherited method)
return the constant NaN (not a Number) in my representation.
Here, based on the assumption that division of zero by zero generates a NaN
(which is defined as such in the IEEE standard).
If a subclass does not, it has to redefine this method and generate a NaN differently

o  infinity
(comment from inherited method)
return an instance of myself which represents positive infinity (for my instances).
Warning: do not compare equal against infinities;
instead, check using isFinite or isInfinite

o  negativeInfinity
(comment from inherited method)
return an instance of myself which represents negative infinity (for my instances).
Warning: do not compare equal against infinities;
instead, check using isFinite or isInfinite

o  unity
(comment from inherited method)
return something which represents the unity element (for my instances).
That is the neutral element for multiplication.

o  zero
there are no instances of me in the system;
however, for fmax computation, it is needed.

errors
o  errorNoInstances

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables

queries
o  fmin
the smallest normalized non-zero value which can be represented
by instances of this class;
should actually be sent to the instance,
because some of my subclasses have an instance-specific representation.
Here, compute it and return a Float (there are no instances of HalfFloat)

o  isAbstract
Return if this class is an abstract class.

Usage example(s):

     HalfFloat isAbstract

o  numBitsInExponent
answer the number of bits in the exponent
This is an IEEE float, where 4 bits are available:
seeeeemm mmmmmmmm

Usage example(s):

     HalfFloat numBitsInExponent 5
     HalfFloat numBitsInMantissa 10
     HalfFloat numHiddenBits     1    
     HalfFloat eBias             15
     HalfFloat emin              -14
     HalfFloat emax              15
     HalfFloat fmin              
     HalfFloat fmax              

o  numBitsInMantissa
answer the number of bits in the mantissa (the significant).
This is an IEEE binary16, where 11 bits are available.
The hidden bit is not counted here.
seeeeemm mmmmmmmm

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



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 09:10:03 GMT