5444
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
5374
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
5 |
All Rights Reserved
|
5335
|
6 |
|
5374
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
5277
|
14 |
"{ Package: 'stx:libbasic2' }"
|
|
15 |
|
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
|
18 |
LimitedPrecisionReal variableByteSubclass:#HalfFloat
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Magnitude-Numbers'
|
|
23 |
!
|
|
24 |
|
|
25 |
!HalfFloat class methodsFor:'documentation'!
|
|
26 |
|
5374
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
5277
|
42 |
documentation
|
|
43 |
"
|
|
44 |
HalfFloats represent rational numbers with very very limited precision.
|
|
45 |
There are no instances of it to be created - halfFloats are only possibly stored
|
|
46 |
inside instancs of HalfFloatArray, which are presented as floats or shortFloats when accessd.
|
|
47 |
However, this class is provided for queries about precision, bits in mantissa etc.
|
|
48 |
|
|
49 |
Representation:
|
|
50 |
16bit single precision IEEE floats
|
|
51 |
10 bit fraction + 1 hidden bit, providing a precision of 11bits,
|
|
52 |
5 bit exponent,
|
|
53 |
6 decimal digits (approx.)
|
|
54 |
|
|
55 |
Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation
|
|
56 |
|
|
57 |
[author:]
|
|
58 |
Claus Gittinger
|
|
59 |
|
|
60 |
[see also:]
|
|
61 |
Number
|
|
62 |
Float LongFloat Fraction FixedPoint Integer Complex
|
|
63 |
HalfFloatArray FloatArray DoubleArray
|
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!HalfFloat class methodsFor:'queries'!
|
|
68 |
|
|
69 |
eBias
|
|
70 |
"Answer the exponent's bias;
|
|
71 |
that is the offset of the zero exponent when stored"
|
|
72 |
|
|
73 |
^ 15
|
|
74 |
!
|
|
75 |
|
|
76 |
emax
|
|
77 |
^ 15
|
|
78 |
!
|
|
79 |
|
|
80 |
emin
|
|
81 |
^ -14
|
|
82 |
!
|
|
83 |
|
|
84 |
numBitsInExponent
|
|
85 |
"answer the number of bits in the exponent
|
|
86 |
This is an IEEE float, where 4 bits are available:
|
|
87 |
seeeemmm mmmmmmmm
|
|
88 |
"
|
|
89 |
|
|
90 |
^ 4
|
5335
|
91 |
!
|
|
92 |
|
|
93 |
numBitsInMantissa
|
|
94 |
"answer the number of bits in the mantissa (the significant).
|
|
95 |
This is an IEEE binary16, where 11 bits are available (the hidden bit is not counted here):
|
|
96 |
seeeemmm mmmmmmmm
|
|
97 |
"
|
|
98 |
|
|
99 |
^ 11
|
|
100 |
!
|
|
101 |
|
|
102 |
radix
|
|
103 |
"answer the radix of a Float's exponent
|
|
104 |
This is an IEEE float, which is represented as binary"
|
|
105 |
|
|
106 |
^ 2
|
5277
|
107 |
! !
|
|
108 |
|
|
109 |
!HalfFloat class methodsFor:'documentation'!
|
|
110 |
|
|
111 |
version_CVS
|
|
112 |
^ '$Header$'
|
|
113 |
! !
|
|
114 |
|