HalfFloat.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 5444 800ebf99147b
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:

"{ Encoding: utf8 }"

"
 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.
"
"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

LimitedPrecisionReal variableByteSubclass:#HalfFloat
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Magnitude-Numbers'
!

!HalfFloat class methodsFor:'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.

"
!

documentation
"
    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:
            16bit single precision IEEE floats
            10 bit fraction + 1 hidden bit, providing a precision of 11bits,
            5 bit exponent,
            6 decimal digits (approx.)

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

    [author:]
        Claus Gittinger

    [see also:]
        Number
        Float LongFloat Fraction FixedPoint Integer Complex
        HalfFloatArray FloatArray DoubleArray
"
! !

!HalfFloat class methodsFor:'queries'!

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

    ^ 15
!

emax
    ^ 15
!

emin
    ^ -14
!

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

    ^ 4
!

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):
        seeeemmm mmmmmmmm
    "

    ^ 11
!

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

    ^ 2 
! !

!HalfFloat class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !