QuadFloat.st
author Claus Gittinger <cg@exept.de>
Fri, 22 Nov 2019 04:41:30 +0100
changeset 5268 d3a464884f60
parent 5267 a9529d2468bb
child 5269 83163a7005f1
permissions -rw-r--r--
#FEATURE by exept class: QuadFloat class definition changed: #printOn: class: QuadFloat class added: #defaultPrintFormat #initialize
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5264
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
     1
"{ Encoding: utf8 }"
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
     2
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:libbasic2' }"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: Smalltalk }"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
LimitedPrecisionReal variableByteSubclass:#QuadFloat
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:'QuadFloatZero QuadFloatOne Pi E Epsilon NaN PositiveInfinity
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
    10
		NegativeInfinity Halfpi HalfpiNegative Phi DefaultPrintFormat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
    11
		DefaultPrintfFormat'
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
	poolDictionaries:''
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
	category:'Magnitude-Numbers'
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
    16
!QuadFloat primitiveDefinitions!
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
    17
%{
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    18
#define SUPPORT_QUADFLOAT
5027
49e378bf72b7 leftover debug prints
Claus Gittinger <cg@exept.de>
parents: 5025
diff changeset
    19
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    20
#include <math.h>
4998
1ed27f918576 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4997
diff changeset
    21
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    22
extern float128_t STX_qadd(float128_t, float128_t, int);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    23
extern float128_t STX_qmul(float128_t, float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    24
extern float128_t STX_qdiv(float128_t, float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    25
extern float128_t STX_qneg(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    26
extern float128_t STX_qabs(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    27
extern float128_t STX_qfloor(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    28
extern float128_t STX_qfrexp(float128_t, int*);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    29
extern float128_t STX_qceil(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    30
extern float128_t STX_qlog(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    31
extern float128_t STX_qlog10(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    32
extern float128_t STX_qlog2(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    33
extern float128_t STX_qexp(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    34
extern float128_t STX_qsin(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    35
extern float128_t STX_qcos(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    36
extern float128_t STX_qtan(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    37
extern float128_t STX_qsinh(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    38
extern float128_t STX_qcosh(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    39
extern float128_t STX_qtanh(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    40
extern float128_t STX_qasin(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    41
extern float128_t STX_qacos(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    42
extern float128_t STX_qatan(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    43
extern float128_t STX_qasinh(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    44
extern float128_t STX_qacosh(float128_t);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    45
extern float128_t STX_qatanh(float128_t);
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    46
extern float128_t STX_qZero;
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    47
extern float128_t STX_dbltoq(double);
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    48
extern float128_t STX_inttoq(long);
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    49
extern double STX_qtodbl(float128_t);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    50
extern int STX_qisNan(float128_t*);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
    51
extern int STX_qprcmp(float128_t*, float128_t*);
5013
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
    52
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    53
#define STX_qisfinite(q)    (!STX_qisNan(&(q)) && !STX_qisInf(&(q)))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    54
#define STX_qeq(x1, x2)     (STX_qprcmp (&(x1), &(x2)) == 0)
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    55
#define STX_qneq(x1, x2)    (STX_qprcmp (&(x1), &(x2)) != 0)
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    56
#define STX_qgt(x1, x2)     (STX_qprcmp (&(x1), &(x2)) > 0)
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    57
#define STX_qge(x1, x2)     (STX_qprcmp (&(x1), &(x2)) >= 0)
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    58
#define STX_qlt(x1, x2)     (STX_qprcmp (&(x1), &(x2)) < 0)
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    59
#define STX_qle(x1, x2)     (STX_qprcmp (&(x1), &(x2)) <= 0)
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    60
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    61
#ifdef __win32__
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    62
/*
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    63
 * no finite(x) ?
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    64
 * no isnan(x) ?
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    65
 */
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    66
# ifndef isnan
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    67
#  define isnan(x)      \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    68
	((((unsigned int *)(&x))[0] == 0x00000000) && \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    69
	 (((unsigned int *)(&x))[1] == 0xFFF80000))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    70
# endif
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    71
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    72
# ifndef isPositiveInfinity
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    73
#  define isPositiveInfinity(x) \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    74
	((((unsigned int *)(&x))[0] == 0x00000000) && \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    75
	 (((unsigned int *)(&x))[1] == 0x7FF00000))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    76
# endif
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    77
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    78
# ifndef isNegativeInfinity
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    79
#  define isNegativeInfinity(x) \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    80
	((((unsigned int *)(&x))[0] == 0x00000000) && \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    81
	 (((unsigned int *)(&x))[1] == 0xFFF00000))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    82
# endif
5014
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
    83
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    84
# ifndef isinf
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    85
#  define isinf(x) \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    86
	((((unsigned int *)(&x))[0] == 0x00000000) && \
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    87
	 ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    88
# endif
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    89
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    90
# ifndef isfinite
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    91
#  define isfinite(x) (!isinf(x) && !isnan(x))
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    92
# endif
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    93
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
    94
#else // not win32
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    95
#endif
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
    96
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    97
%}
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    98
! !
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
    99
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   100
!QuadFloat primitiveVariables!
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   101
%{
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   102
%}
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   103
! !
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   104
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   105
!QuadFloat primitiveFunctions!
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   106
%{
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   107
%}
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   108
! !
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   109
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
!QuadFloat class methodsFor:'documentation'!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
documentation
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    QuadFloats represent rational numbers with limited precision
5007
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   115
    and are mapped to IEEE quadruple precision format (128bit),
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   116
    also called binary128.
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   117
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    If the underlying cpu supports them natively, the machine format (long double) is
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    used. Otherwise, a software emulation is done, which is much slower.
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    Thus only use them, if you really need the additional precision;
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    if not, use Float (which are doubles) or LongFloats which usually have IEEE extended precision (80bit).
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    QuadFloats give you definite 128 bit quadruple floats,
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    thus, code using quadFloats is guaranteed to be portable from one architecture to another.
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    Representation:
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   127
	    128bit quadruple IEEE floats (16bytes);
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   128
	    112 bit mantissa,
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   129
	    16 bit exponent,
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   130
	    34 decimal digits (approx.)
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
4992
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   132
    On Sparc CPUs, this is a native supported type (long double) and fast;
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   133
    on x86 CPUs, this is emulated and slow.
ee1d80769d4c first code for add
Claus Gittinger <cg@exept.de>
parents: 4991
diff changeset
   134
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    Mixed mode arithmetic:
5007
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   136
	quadFloat op anyFloat    -> quadFloat
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   137
	anyFloat op quadFloat    -> quadFloat
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    Range and precision of storage formats: see LimitedPrecisionReal >> documentation
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    [author:]
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   142
	Claus Gittinger
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    [see also:]
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   145
	Number
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   146
	Float ShortFloat LongFloat Fraction FixedPoint Integer Complex
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   147
	FloatArray DoubleArray
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   148
	https://en.wikipedia.org/wiki/Extended_precision
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
! !
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
!QuadFloat class methodsFor:'instance creation'!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
basicNew
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    "return a new quadFloat - here we return 0.0
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
     - QuadFloats are usually NOT created this way ...
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
     Its implemented here to allow things like binary store & load
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
     of quadFloats.
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
     (but it is not a good idea to store the bits of a float - the reader might have a
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
      totally different representation - so floats should be
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
      binary stored in a device independent format)."
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
%{  /* NOCONTEXT */
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   164
#ifdef SUPPORT_QUADFLOAT
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    OBJ newFloat;
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   166
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   167
    if (sizeof(long double) == sizeof(float128_t)) {
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   168
	__qMKLFLOAT(newFloat, 0.0);   /* OBJECT ALLOCATION */
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    } else {
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   170
	float128_t qf = STX_qZero;
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   171
	__qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    }
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    RETURN (newFloat);
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   174
#endif /* SUPPORT_QUADFLOAT */
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   175
%}.
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   176
    self error:'QuadFloats not supported on this patform'
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    "Created: / 06-06-2019 / 17:18:58 / Claus Gittinger"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
fromFloat:aFloat
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "return a new quadFloat, given a float value"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
%{  /* NOCONTEXT */
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   185
#ifdef SUPPORT_QUADFLOAT
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    OBJ newFloat;
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    if (__isFloatLike(aFloat)) {
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   189
	double f = __floatVal(aFloat);
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   190
	float128_t qf;
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   191
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   192
	qf = STX_dbltoq (f);
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   193
	__qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   194
	RETURN (newFloat);
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    }
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   196
#endif /* SUPPORT_QUADFLOAT */
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
%}.
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   198
    aFloat isFloat ifTrue:[
4997
55c76587b49c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4994
diff changeset
   199
	self errorUnsupported
4993
c7956a3ab780 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
   200
    ].
4997
55c76587b49c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4994
diff changeset
   201
    ArgumentError raise
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
     QuadFloat fromFloat:123.0
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
     123.0 asQuadFloat
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
     123 asQuadFloat
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    "
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    "Created: / 06-06-2019 / 18:01:03 / Claus Gittinger"
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   210
!
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   211
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   212
fromInteger:anInteger
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   213
    "return a new quadFloat, given an integer value"
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   214
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   215
%{  /* NOCONTEXT */
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   216
#ifdef SUPPORT_QUADFLOAT
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   217
    OBJ newFloat;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   218
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   219
    if (__isSmallInteger(anInteger)) {
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   220
	INT iVal = __intVal(anInteger);
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   221
	float128_t qf;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   222
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   223
	qf = STX_inttoq( (long)iVal );
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   224
	__qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   225
	RETURN (newFloat);
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   226
    }
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   227
#endif /* SUPPORT_QUADFLOAT */
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   228
%}.
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   229
    ^ super fromInteger:anInteger
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   230
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   231
    "
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   232
     QuadFloat fromInteger:123
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   233
     123 asQuadFloat
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   234
    "
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   235
!
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   236
5014
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   237
fromLongFloat:aFloat
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   238
    "return a new quadFloat, given a long float value"
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   239
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   240
%{  /* NOCONTEXT */
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   241
#ifdef xSUPPORT_QUADFLOAT
5014
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   242
    OBJ newFloat;
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   243
    union {
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   244
	LONGFLOAT_t lf;         // is long double
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   245
	extFloat80_t ef;        // is 80bit ext
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   246
	float128_t qf;          // is 128bit quad
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   247
    } u;
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   248
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   249
    if (__isLongFloat(aFloat)) {
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   250
	u.lf = __longFloatVal(aFloat);
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   251
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   252
	if (sizeof(LONGFLOAT_t) == 16) {
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   253
	    // longFloat is already 128 bits in size (sparc)
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   254
	    __qMKQFLOAT(newFloat, u.qf);   /* OBJECT ALLOCATION */
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   255
	    RETURN (newFloat);
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   256
	}
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   257
	if (sizeof(LONGFLOAT_t) < 16) {
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   258
	    // assume 80bit extended float format (amd64, x86_64)
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   259
	    u.qf = extF80_to_f128( u.ef);
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   260
	    __qMKQFLOAT(newFloat, u.qf);   /* OBJECT ALLOCATION */
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   261
	    RETURN (newFloat);
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   262
	}
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   263
	// fall into error case
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   264
    }
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   265
#endif /* SUPPORT_QUADFLOAT */
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   266
%}.
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   267
    aFloat isLongFloat ifTrue:[
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   268
	self errorUnsupported
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   269
    ].
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   270
    ArgumentError raise
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   271
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   272
    "
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   273
     QuadFloat fromLongFloat:123.0 asLongFloat
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   274
    "
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   275
!
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   276
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   277
fromShortFloat:aShortFloat
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   278
    "return a new quadFloat, given a float value"
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   279
5013
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   280
    ^ self fromFloat:(aShortFloat asFloat)
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   281
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   282
    "
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   283
     QuadFloat fromShortFloat:123.0 asShortFloat
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   284
    "
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   285
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   286
    "Created: / 08-06-2019 / 03:28:37 / Claus Gittinger"
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
! !
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   289
!QuadFloat class methodsFor:'accessing'!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   290
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   291
defaultPrintFormat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   292
    "/ by default, I will print 19 digits
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   293
    "/  ShortFloat pi   -> 3.141593  
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   294
    "/  Float pi        -> 3.14159265358979  
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   295
    "/  LongFloat pi    -> 3.141592653589793239  
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   296
    "/  QuadFloat pi    -> 3.141592653589793239  
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   297
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   298
    ^ DefaultPrintFormat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   299
! !
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   300
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   301
!QuadFloat class methodsFor:'class initialization'!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   302
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   303
initialize
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   304
    DefaultPrintFormat := '.34'.  "/ 34 valid digits
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   305
    DefaultPrintfFormat := '%34f'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   306
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   307
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   308
     self initialize
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   309
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   310
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   311
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   312
     DefaultPrintFormat := '.19'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   313
     QuadFloat pi printString.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   314
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   315
     DefaultPrintFormat := '.9'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   316
     QuadFloat pi printString.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   317
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   318
     DefaultPrintFormat := '.6'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   319
     QuadFloat pi printString.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   320
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   321
! !
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   322
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
!QuadFloat class methodsFor:'coercing & converting'!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
coerce:aNumber
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "convert the argument aNumber into an instance of the receiver's class and return it."
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    ^ aNumber asQuadFloat.
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    "Created: / 06-06-2019 / 16:51:01 / Claus Gittinger"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
! !
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
!QuadFloat class methodsFor:'constants'!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
NaN
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   336
    "return a quadFloat which represents not-a-Number (i.e. an invalid number)"
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   337
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   338
    |nan|
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    NaN isNil ifTrue:[
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   341
%{  /* NOCONTEXT */
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   342
#ifdef xSUPPORT_QUADFLOAT
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   343
	{
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   344
	    OBJ newFloat;
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   345
	    float128_t qf;
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   346
5014
eb02b6118108 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
   347
	    softfloat_commonNaNToF128M( (uint32_t*)(&qf) );
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   348
	    __qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   349
	    nan = newFloat;
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   350
	}
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   351
#endif /* SUPPORT_QUADFLOAT */
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   352
%}.
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   353
	NaN := nan
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    ].
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    ^ NaN
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
e
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    "return the constant e as quadFloat"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
    E isNil ifTrue:[
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   362
	"/ eDigits has enough digits for 128bit IEEE quads
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   363
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   364
	E  := self readFrom:(Number eDigits)
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    ].
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    ^ E
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    "Created: / 06-06-2019 / 17:01:54 / Claus Gittinger"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   371
infinity
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   372
    "return a quadFloat which represents +INF"
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   373
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   374
    |inf|
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   375
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   376
    PositiveInfinity isNil ifTrue:[
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   377
%{  /* NOCONTEXT */
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   378
#ifdef xSUPPORT_QUADFLOAT
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   379
	{
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   380
	    OBJ newFloat;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   381
	    struct uint128 uiZ;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   382
	    union ui128_f128 uZ;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   383
	    float128_t qf;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   384
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   385
	    uiZ.v64 = packToF128UI64( 0, 0x7FFF, 0 );
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   386
	    uiZ.v0 = 0;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   387
	    uZ.ui = uiZ;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   388
	    qf = uZ.f;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   389
	    __qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   390
	    inf = newFloat;
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   391
	}
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   392
#endif /* SUPPORT_QUADFLOAT */
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   393
%}.
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   394
	PositiveInfinity := inf
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   395
    ].
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   396
    ^ PositiveInfinity
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   397
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   398
    "Created: / 08-06-2019 / 14:05:26 / Claus Gittinger"
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   399
!
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   400
5012
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   401
negativeInfinity
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   402
    "return a quadFloat which represents -INF"
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   403
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   404
    |inf|
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   405
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   406
    NegativeInfinity isNil ifTrue:[
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   407
%{  /* NOCONTEXT */
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   408
#ifdef xSUPPORT_QUADFLOAT
5013
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   409
	{
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   410
	    OBJ newFloat;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   411
	    struct uint128 uiZ;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   412
	    union ui128_f128 uZ;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   413
	    float128_t qf;
5012
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   414
5013
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   415
	    uiZ.v64 = packToF128UI64( 1, 0x7FFF, 0 );
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   416
	    uiZ.v0 = 0;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   417
	    uZ.ui = uiZ;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   418
	    qf = uZ.f;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   419
	    __qMKQFLOAT(newFloat, qf);   /* OBJECT ALLOCATION */
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   420
	    inf = newFloat;
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   421
	}
5012
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   422
#endif /* SUPPORT_QUADFLOAT */
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   423
%}.
5013
00262ae1cef1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5012
diff changeset
   424
	NegativeInfinity := inf
5012
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   425
    ].
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   426
    ^ NegativeInfinity
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   427
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   428
    "Created: / 08-06-2019 / 14:05:50 / Claus Gittinger"
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   429
!
bd4e0475f9ea #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5011
diff changeset
   430
5264
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   431
phi
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   432
    "return the constant phi as quadFloat"
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   433
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   434
    Phi isNil ifTrue:[
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   435
	"/ phiDigits has enough digits for 128bit IEEE quads
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   436
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   437
	Phi  := self readFrom:(Number phiDigits)
5264
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   438
    ].
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   439
    ^ Phi
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   440
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   441
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   442
!
e01656e04937 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
   443
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
pi
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    "return the constant pi as quadFloat"
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    Pi isNil ifTrue:[
4991
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   448
	"/ piDigits has enough digits for 128bit IEEE quads
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   449
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
9d86d1eb2a65 compilable, at least
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
   450
	Pi  := self readFrom:(Number piDigits)
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    ].
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    ^ Pi
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    "Created: / 06-06-2019 / 17:09:51 / Claus Gittinger"
5006
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   455
!
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   456
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   457
unity
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   458
    "return the neutral element for multiplication (1.0) as QuadFloat"
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   459
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   460
    QuadFloatOne isNil ifTrue:[
5007
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   461
	QuadFloatOne := 1.0 asQuadFloat.
5006
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   462
    ].
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   463
    ^ QuadFloatOne
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   464
be75f4702e37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5005
diff changeset
   465
    "Created: / 07-06-2019 / 03:26:38 / Claus Gittinger"
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   466
!
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   467
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   468
zero
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   469
    "return the neutral element for addition (0.0) as QuadFloat"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   470
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   471
    QuadFloatZero isNil ifTrue:[
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
   472
	QuadFloatZero := 0.0 asQuadFloat
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   473
    ].
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   474
    ^ QuadFloatZero
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   475
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
   476
    "Created: / 07-06-2019 / 09:22:56 / Claus Gittinger"
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
! !
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
   479
!QuadFloat class methodsFor:'error reportng'!
4994
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   480
4997
55c76587b49c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4994
diff changeset
   481
errorUnsupported
55c76587b49c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4994
diff changeset
   482
    self error:'QuadFloats not supported on this patform'
55c76587b49c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4994
diff changeset
   483
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
   484
    "Created: / 07-06-2019 / 02:44:39 / Claus Gittinger"
4994
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   485
! !
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   486
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   487
!QuadFloat class methodsFor:'queries'!
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   488
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   489
epsilon
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   490
    "return the maximum relative spacing of instances of mySelf
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   491
     (i.e. the value-delta of the least significant bit)"
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   492
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   493
    Epsilon isNil ifTrue:[
5020
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
   494
	Epsilon := self computeEpsilon.
5017
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   495
    ].
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   496
    ^ Epsilon
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   497
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   498
    "
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   499
     self epsilon
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   500
    "
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   501
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   502
    "Created: / 10-06-2019 / 21:21:18 / Claus Gittinger"
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   503
!
47f09d7ee9b1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
   504
5018
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   505
exponentCharacter
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   506
    "return the character used to print between mantissa an exponent.
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   507
     Also used by the scanner when reading numbers."
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   508
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   509
    ^ $Q
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   510
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   511
    "Created: / 10-06-2019 / 21:28:04 / Claus Gittinger"
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   512
!
ce2e00107844 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5017
diff changeset
   513
5025
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   514
numBitsInExponent
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   515
    "answer the number of bits in the exponent
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   516
     the hidden bit is not counted here:
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   517
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   518
     This is an 128bit quadfloat,
5027
49e378bf72b7 leftover debug prints
Claus Gittinger <cg@exept.de>
parents: 5025
diff changeset
   519
	   where 15 bits are available in the exponent:
49e378bf72b7 leftover debug prints
Claus Gittinger <cg@exept.de>
parents: 5025
diff changeset
   520
	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...
5025
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   521
    "
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   522
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   523
    ^ 15
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   524
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   525
    "
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   526
     1.0 class numBitsInExponent -> 11
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   527
     1.0 asShortFloat class numBitsInExponent -> 8
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   528
     1.0 asLongFloat class numBitsInExponent -> 15
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   529
     1.0 asQuadFloat class numBitsInExponent -> 15
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   530
    "
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   531
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   532
    "Created: / 11-06-2019 / 00:14:55 / Claus Gittinger"
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   533
!
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   534
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   535
numBitsInMantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   536
    "answer the number of bits in the mantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   537
     the hidden bit is not counted here:
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   538
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   539
     This is an 128bit quadfloat,
5007
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   540
	   where 112 bits are available in the mantissa:
97def4a232e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   541
	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm...
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   542
    "
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   543
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   544
    ^ 112
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   545
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   546
    "
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   547
     1.0 class numBitsInMantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   548
     1.0 asShortFloat class numBitsInMantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   549
     1.0 asLongFloat class numBitsInMantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   550
     1.0 asQuadFloat class numBitsInMantissa
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   551
    "
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   552
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   553
    "Created: / 07-06-2019 / 03:24:20 / Claus Gittinger"
5056
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   554
!
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   555
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   556
radix
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   557
    "answer the radix of a QuadFloat's exponent
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   558
     This is an IEEE float, which is represented as binary"
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   559
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   560
    ^ 2 "must be careful here, whenever ST/X is used on VAX or a 370"
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   561
0744a9b601c5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5027
diff changeset
   562
    "Created: / 19-07-2019 / 17:28:00 / Claus Gittinger"
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   563
! !
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
   564
4994
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   565
!QuadFloat methodsFor:'arithmetic'!
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   566
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   567
* aNumber
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   568
    "return the product of the receiver and the argument."
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   569
5074
7eaede72d204 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 5056
diff changeset
   570
    aNumber class == QuadFloat ifTrue:[
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   571
	^ aNumber productFromQuadFloat:self
5074
7eaede72d204 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 5056
diff changeset
   572
    ].
7eaede72d204 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 5056
diff changeset
   573
5075
18cba5cb7d94 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 5074
diff changeset
   574
    thisContext isReallyRecursive ifTrue:[self error].
4994
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   575
    ^ aNumber productFromQuadFloat:self
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   576
!
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   577
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   578
+ aNumber
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   579
    "return the sum of the receiver and the argument, aNumber"
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   580
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   581
    ^ aNumber sumFromQuadFloat:self
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   582
!
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   583
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   584
- aNumber
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   585
    "return the difference of the receiver and the argument, aNumber"
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   586
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   587
    ^ aNumber differenceFromQuadFloat:self
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   588
!
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   589
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   590
/ aNumber
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   591
    "return the quotient of the receiver and the argument, aNumber"
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   592
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   593
    aNumber isZero ifTrue:[
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   594
	"
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   595
	 No, you shalt not divide by zero
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   596
	"
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   597
	^ ZeroDivide raiseRequestWith:thisContext.
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   598
    ].
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   599
    ^ aNumber quotientFromQuadFloat:self
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   600
!
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   601
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   602
abs
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   603
    "return the absolute value of the receiver
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   604
     reimplemented here for speed"
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   605
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   606
%{  /* NOCONTEXT */
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   607
#ifdef SUPPORT_QUADFLOAT
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   608
    OBJ newFloat;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   609
    float128_t result, myVal;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   610
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   611
    myVal = __quadFloatVal(self);
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   612
    result = STX_qabs(myVal);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   613
    __qMKQFLOAT(newFloat, result);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   614
    RETURN ( newFloat );
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   615
#endif
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   616
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   617
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   618
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   619
ceiling
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   620
    "return the smallest integer which is greater or equal to the receiver."
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   621
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   622
    |val|
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   623
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   624
%{
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   625
    float128_t qVal;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   626
    float128_t qMinInt;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   627
    float128_t qMaxInt;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   628
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   629
    qVal = __quadFloatVal(self);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   630
    qVal = STX_qceil(qVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   631
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   632
    qMinInt = STX_dbltoq((double)_MIN_INT);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   633
    qMaxInt = STX_dbltoq((double)_MAX_INT);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   634
    if (STX_qge(qVal, qMinInt) && STX_qle(qVal, qMaxInt)) {
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   635
	double dVal = STX_qtodbl(qVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   636
	RETURN ( __mkSmallInteger( (INT) dVal ) );
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   637
    }
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   638
    __qMKQFLOAT(val, qVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   639
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   640
    ^ val asInteger
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   641
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   642
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   643
     0.5 asQuadFloat ceiling
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   644
     0.5 asQuadFloat ceilingAsFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   645
     -0.5 asQuadFloat ceiling
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   646
     -0.5 asQuadFloat ceilingAsFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   647
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   648
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   649
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   650
ceilingAsFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   651
    "return the smallest integer-valued float greater or equal to the receiver.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   652
     This is much like #ceiling, but avoids a (possibly expensive) conversion
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   653
     of the result to an integer.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   654
     It may be useful, if the result is to be further used in another float-operation."
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   655
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   656
%{  /* NOCONTEXT */
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   657
#ifdef SUPPORT_QUADFLOAT
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   658
    OBJ newFloat;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   659
    float128_t result, myVal;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   660
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   661
    myVal = __quadFloatVal(self);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   662
    result = STX_qceil(myVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   663
    __qMKQFLOAT(newFloat, result);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   664
    RETURN ( newFloat );
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   665
#endif
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   666
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   667
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   668
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   669
cos
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   670
    "return the cosine of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   671
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   672
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   673
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   674
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   675
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   676
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   677
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   678
    result = STX_qcos(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   679
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   680
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   681
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   682
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   683
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   684
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   685
cosh
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   686
    "return the hyperbolic cosine of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   687
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   688
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   689
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   690
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   691
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   692
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   693
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   694
    result = STX_qcosh(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   695
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   696
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   697
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   698
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   699
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   700
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   701
exp
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   702
    "return e raised to the power of the receiver"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   703
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   704
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   705
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   706
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   707
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   708
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   709
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   710
    result = STX_qexp(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   711
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   712
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   713
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   714
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   715
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   716
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   717
exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   718
    "extract a normalized float's exponent.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   719
     The returned value depends on the float-representation of
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   720
     the underlying machine and is therefore highly unportable.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   721
     This is not for general use.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   722
     This assumes that the mantissa is normalized to
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   723
     0.5 .. 1.0 and the float's value is: mantissa * 2^exp"
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   724
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   725
%{  /* NOCONTEXT */
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   726
    float128_t myVal;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   727
    float128_t frac;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   728
    int exp;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   729
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   730
    myVal = __quadFloatVal(self);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   731
#if 1
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   732
    // should we?
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   733
    if (! (STX_qisNan(&myVal) || STX_qisInf(&myVal)))
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   734
#endif
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   735
    {
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   736
	frac = STX_qfrexp(myVal, &exp);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   737
	RETURN (__mkSmallInteger(exp));
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   738
    }
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   739
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   740
    ^ super exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   741
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   742
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   743
     1.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   744
     1.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   745
     2.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   746
     2.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   747
     3.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   748
     3.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   749
     4.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   750
     4.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   751
     0.5 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   752
     0.5 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   753
     0.4 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   754
     0.4 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   755
     0.25 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   756
     0.25 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   757
     0.2 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   758
     0.2 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   759
     0.00000011111 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   760
     0.00000011111 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   761
     0.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   762
     0.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   763
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   764
     1e1000 exponent -> error (INF)
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   765
     1e1000 asQuadFloat exponent -> error (INF)
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   766
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   767
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   768
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   769
floor
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   770
    "return the integer nearest the receiver towards negative infinity."
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   771
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   772
    |val|
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   773
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   774
%{
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   775
    float128_t qVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   776
    float128_t qMinInt;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   777
    float128_t qMaxInt;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   778
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   779
    qVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   780
    qVal = STX_qfloor(qVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   781
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   782
    qMinInt = STX_dbltoq((double)_MIN_INT);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   783
    qMaxInt = STX_dbltoq((double)_MAX_INT);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   784
    if (STX_qge(qVal, qMinInt) && STX_qle(qVal, qMaxInt)) {
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   785
	double dVal = STX_qtodbl(qVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   786
	RETURN ( __mkSmallInteger( (INT) dVal ) );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   787
    }
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   788
    __qMKQFLOAT(val, qVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   789
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   790
    ^ val asInteger
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   791
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   792
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   793
     0.5 asQuadFloat floor
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   794
     0.5 asQuadFloat floorAsFloat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   795
     -0.5 asQuadFloat floor
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   796
     -0.5 asQuadFloat floorAsFloat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   797
    "
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   798
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   799
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   800
floorAsFloat
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   801
    "return the integer nearest the receiver towards negative infinity as a float.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   802
     This is much like #floor, but avoids a (possibly expensive) conversion
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   803
     of the result to an integer.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   804
     It may be useful, if the result is to be further used in another float-operation."
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   805
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   806
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   807
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   808
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   809
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   810
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   811
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   812
    result = STX_qfloor(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   813
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   814
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   815
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   816
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   817
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   818
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   819
ln
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   820
    "return natural logarithm of the receiver."
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   821
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   822
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   823
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   824
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   825
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   826
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   827
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   828
    result = STX_qlog(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   829
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   830
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   831
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   832
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   833
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   834
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   835
log
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   836
    "return log base 10 of the receiver.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   837
     Alias for log:10."
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   838
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   839
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   840
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   841
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   842
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   843
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   844
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   845
    result = STX_qlog10(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   846
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   847
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   848
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   849
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   850
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   851
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   852
log2
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   853
    "return logarithm dualis of the receiver."
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   854
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   855
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   856
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   857
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   858
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   859
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   860
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   861
    result = STX_qlog2(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   862
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   863
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   864
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   865
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   866
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   867
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   868
mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   869
    "extract a normalized float's mantissa.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   870
     The returned value depends on the float-representation of
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   871
     the underlying machine and is therefore highly unportable.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   872
     This is not for general use.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   873
     This assumes that the mantissa is normalized to
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   874
     0.5 .. 1.0 and the float's value is mantissa * 2^exp"
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   875
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   876
%{  /* NOCONTEXT */
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   877
    float128_t myVal;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   878
    float128_t frac;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   879
    int exp;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   880
    OBJ newFloat;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   881
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   882
    myVal = __quadFloatVal(self);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   883
    // ouch: math libs seem to not care for NaN here;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   884
#if 1
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   885
    // should we?
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   886
    if (! (STX_qisNan(&myVal) || STX_qisInf(&myVal)))
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   887
#endif
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   888
    {
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   889
	frac = STX_qfrexp(myVal, &exp);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   890
	__qMKQFLOAT(newFloat, frac);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   891
	RETURN ( newFloat );
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   892
    }
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   893
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   894
    ^ super mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   895
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   896
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   897
     1.0 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   898
     1.0 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   899
     1.0 mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   900
     1.0 asQuadFloat mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   901
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   902
     0.25 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   903
     0.25 asQuadFloat exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   904
     0.25 mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   905
     0.25 asQuadFloat mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   906
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   907
     0.00000011111 exponent
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   908
     0.00000011111 mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   909
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   910
     1e1000 mantissa
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   911
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   912
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   913
    "Modified: / 20-06-2017 / 11:37:13 / cg"
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   914
    "Modified (comment): / 26-05-2019 / 03:12:55 / Claus Gittinger"
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   915
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   916
5021
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   917
negated
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   918
    "return the receiver negated"
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   919
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   920
%{  /* NOCONTEXT */
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   921
#ifdef SUPPORT_QUADFLOAT
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   922
    OBJ newFloat;
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   923
    float128_t result, myVal;
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   924
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   925
    myVal = __quadFloatVal(self);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
   926
    result = STX_qneg(myVal);
5021
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   927
    __qMKQFLOAT(newFloat, result);
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   928
    RETURN ( newFloat );
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   929
#endif
073ff185359b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5020
diff changeset
   930
%}.
5025
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   931
!
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   932
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   933
rem: aNumber
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   934
    "return the floating point remainder of the receiver and the argument, aNumber"
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   935
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   936
    aNumber isZero ifTrue:[
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   937
	"
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   938
	 No, you shalt not divide by zero
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   939
	"
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   940
	^ ZeroDivide raiseRequestWith:thisContext.
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   941
    ].
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
   942
    ^ aNumber remainderFromLongFloat:self
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   943
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   944
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   945
sin
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   946
    "return the sine of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   947
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   948
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   949
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   950
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   951
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   952
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   953
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   954
    result = STX_qsin(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   955
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   956
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   957
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   958
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   959
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   960
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   961
sinh
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   962
    "return the hyperbolic sine of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   963
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   964
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   965
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   966
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   967
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   968
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   969
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   970
    result = STX_qsinh(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   971
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   972
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   973
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   974
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   975
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   976
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   977
tan
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   978
    "return the tangent of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   979
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   980
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   981
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   982
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   983
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   984
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   985
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   986
    result = STX_qtan(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   987
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   988
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   989
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   990
%}.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   991
!
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   992
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   993
tanh
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   994
    "return the hyperbolic tangent of the receiver (interpreted as radians)"
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   995
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   996
%{  /* NOCONTEXT */
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   997
#ifdef SUPPORT_QUADFLOAT
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   998
    OBJ newFloat;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
   999
    float128_t result, myVal;
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1000
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1001
    myVal = __quadFloatVal(self);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1002
    result = STX_qtanh(myVal);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1003
    __qMKQFLOAT(newFloat, result);
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1004
    RETURN ( newFloat );
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1005
#endif
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1006
%}.
4994
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
  1007
! !
246159e1784d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
  1008
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1009
!QuadFloat methodsFor:'coercing & converting'!
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1010
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1011
asFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1012
    "return a Float with same value as the receiver.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1013
     Raises an error if the receiver exceeds the float range."
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1014
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1015
%{  /* NOCONTEXT */
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1016
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1017
    OBJ newFloat;
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1018
    float128_t qVal = __quadFloatVal(self);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1019
    double dVal = STX_qtodbl(qVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1020
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1021
    if (isfinite(dVal) || !STX_qisfinite(qVal)) {
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1022
	__qMKFLOAT(newFloat, dVal);
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1023
	RETURN ( newFloat );
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1024
    }
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1025
%}.
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1026
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1027
     value out of range
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1028
     if you need -INF for a zero receiver, try Number trapInfinity:[...]
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1029
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1030
    ^ self class
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1031
	raise:#infiniteResultSignal
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1032
	receiver:self
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1033
	selector:#asFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1034
	arguments:#()
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1035
	errorString:'receiver is out of the double-precision float range'
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1036
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1037
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1038
     1.0 asQuadFloat asFloat
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1039
    "
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1040
!
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1041
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1042
generality
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1043
    "return the generality value - see ArithmeticValue>>retry:coercing:"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1044
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1045
    ^ 93
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1046
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1047
    "Created: / 07-06-2019 / 09:30:58 / Claus Gittinger"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1048
! !
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1049
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1050
!QuadFloat methodsFor:'comparing'!
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1051
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1052
< aNumber
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1053
    "return true, if the argument is greater"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1054
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1055
    ^ aNumber lessFromQuadFloat:self
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1056
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1057
    "Created: / 07-06-2019 / 09:25:47 / Claus Gittinger"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1058
!
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1059
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1060
= aNumber
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1061
    "return true, if the argument represents the same numeric value
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1062
     as the receiver, false otherwise"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1063
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1064
    ^ aNumber equalFromQuadFloat:self
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1065
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1066
    "Created: / 07-06-2019 / 09:25:27 / Claus Gittinger"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1067
!
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1068
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1069
hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1070
    "return a number for hashing; redefined, since floats compare
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1071
     by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1072
     as 3 hash."
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1073
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1074
    |i|
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1075
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1076
    (self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1077
	i := self asInteger.
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1078
	self = i ifTrue:[
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1079
	    ^ i hash
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1080
	].
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1081
    ].
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1082
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1083
    ^ self asFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1084
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1085
    "
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1086
     1.2345 hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1087
     1.2345 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1088
     1.2345 asLongFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1089
     1.2345 asQuadFloat hash
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1090
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1091
     1.0 hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1092
     1.0 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1093
     1.0 asLongFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1094
     1.0 asQuadFloat hash
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1095
5008
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1096
     0.5 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1097
     0.5 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1098
     0.5 asLongFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1099
     0.5 asQuadFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1100
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1101
     0.25 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1102
     0.25 asShortFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1103
     0.25 asLongFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1104
     0.25 asQuadFloat hash
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1105
    "
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1106
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1107
    "Created: / 07-06-2019 / 09:28:07 / Claus Gittinger"
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1108
! !
9eb7df4b6ce0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1109
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1110
!QuadFloat methodsFor:'double dispatching'!
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1111
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1112
differenceFromQuadFloat:aQuadFloat
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1113
%{
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1114
#ifdef SUPPORT_QUADFLOAT
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1115
    OBJ newFloat;
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1116
    float128_t result, myVal, argVal;
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1117
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1118
    myVal = __quadFloatVal(self);
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1119
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1120
    result = STX_qadd( argVal, myVal, 1 );
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1121
    __qMKQFLOAT(newFloat, result);
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1122
    RETURN ( newFloat );
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1123
#endif // SUPPORT_QUADFLOAT
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1124
%}.
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1125
    self errorUnsupported
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1126
!
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1127
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1128
equalFromQuadFloat:aQuadFloat
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1129
    "sent when aQuadFloat does not know how to compare agaist the receiver, self"
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1130
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1131
%{
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1132
#ifdef SUPPORT_QUADFLOAT
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1133
    OBJ newFloat;
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1134
    float128_t result, myVal, argVal;
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1135
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1136
    myVal = __quadFloatVal(self);
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1137
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1138
    RETURN (STX_qeq(argVal, myVal) ? true : false);
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1139
#endif // SUPPORT_QUADFLOAT
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1140
%}.
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1141
    self errorUnsupported
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1142
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1143
    "Modified: / 08-06-2019 / 13:31:48 / Claus Gittinger"
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1144
!
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1145
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1146
lessFromQuadFloat:aQuadFloat
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1147
    "sent when aQuadFloat does not know how to compare agaist the receiver, self"
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1148
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1149
%{
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1150
#ifdef SUPPORT_QUADFLOAT
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1151
    OBJ newFloat;
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1152
    float128_t result, myVal, argVal;
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1153
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1154
    myVal = __quadFloatVal(self);
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1155
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1156
    RETURN (STX_qlt(argVal, myVal) ? true : false);
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1157
#endif // SUPPORT_QUADFLOAT
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1158
%}.
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1159
    self errorUnsupported
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1160
!
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1161
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1162
productFromQuadFloat:aQuadFloat
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1163
    "sent when aQuadFloat does not know how to multiply the receiver, self"
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1164
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1165
%{
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1166
#ifdef SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1167
    OBJ newFloat;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1168
    float128_t result, myVal, argVal;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1169
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1170
    myVal = __quadFloatVal(self);
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1171
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1172
    result = STX_qmul(myVal, argVal);
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1173
    __qMKQFLOAT(newFloat, result);
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1174
    RETURN ( newFloat );
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1175
#endif // SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1176
%}.
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1177
    self errorUnsupported
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1178
!
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1179
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1180
quotientFromQuadFloat:aQuadFloat
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1181
    "sent when aQuadFloat does not know how to multiply the receiver, self"
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1182
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1183
%{
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1184
#ifdef SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1185
    OBJ newFloat;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1186
    float128_t result, myVal, argVal;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1187
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1188
    myVal = __quadFloatVal(self);
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1189
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1190
    result = STX_qdiv(argVal, myVal);
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1191
    __qMKQFLOAT(newFloat, result);
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1192
    RETURN ( newFloat );
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1193
#endif // SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1194
%}.
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1195
    self errorUnsupported
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1196
!
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1197
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1198
sumFromQuadFloat:aQuadFloat
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1199
    "sent when aQuadFloat does not know how to add the receiver, self"
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1200
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1201
%{
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1202
#ifdef SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1203
    OBJ newFloat;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1204
    float128_t result, myVal, argVal;
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1205
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1206
    myVal = __quadFloatVal(self);
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1207
    argVal = __quadFloatVal(aQuadFloat);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1208
    result = STX_qadd( myVal, argVal, 0 );
5005
37632dff5141 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5004
diff changeset
  1209
    __qMKQFLOAT(newFloat, result);
5004
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1210
    RETURN ( newFloat );
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1211
#endif // SUPPORT_QUADFLOAT
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1212
%}.
52b4d47d9ea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5003
diff changeset
  1213
    self errorUnsupported
5003
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1214
! !
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1215
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1216
!QuadFloat methodsFor:'error reportng'!
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1217
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1218
errorUnsupported
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1219
    self class errorUnsupported
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1220
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1221
    "Modified: / 07-06-2019 / 02:44:51 / Claus Gittinger"
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1222
! !
7a48121b7faa #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5002
diff changeset
  1223
5025
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1224
!QuadFloat methodsFor:'printing'!
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1225
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1226
printOn:aStream
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1227
    PrintfScanf printf:'%e' on:aStream argument:self
5027
49e378bf72b7 leftover debug prints
Claus Gittinger <cg@exept.de>
parents: 5025
diff changeset
  1228
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1229
"/    |mantissa exponent|
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1230
"/
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1231
"/    mantissa := self mantissa.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1232
"/    exponent := self exponent.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1233
"/
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1234
"/    self exponent == 0 ifTrue:[
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1235
"/        mantissa printOn:aStream.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1236
"/        aStream nextPutAll:'.0'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1237
"/        ^ self
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1238
"/    ].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1239
"/    mantissa == 0 ifTrue:[
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1240
"/        "/ a zero mantissa is impossible - except for zero and a few others
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1241
"/        exponent == 0 ifTrue:[ aStream nextPutAll:'0.0'. ^ self].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1242
"/        self == NaN ifTrue:[ aStream nextPutAll:'NAN'. ^ self ].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1243
"/        self == NegativeInfinity ifTrue:[ aStream nextPutAll:'-INF'. ^ self].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1244
"/        self == PositiveInfinity ifTrue:[ aStream nextPutAll:'INF'. ^ self].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1245
"/
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1246
"/        self error:'invalid largeFloat' mayProceed:true.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1247
"/        aStream nextPutAll:'Invalid'. ^ self.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1248
"/    ].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1249
"/
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1250
"/    exponent >= 0 ifTrue:[
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1251
"/        (mantissa bitShift:exponent) printOn:aStream.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1252
"/        aStream nextPutAll:'.0'.
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1253
"/        ^ self
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1254
"/    ].
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1255
"/    ((mantissa / (1 bitShift:exponent negated)) asFixedPoint:6) printOn:aStream.
5025
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1256
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1257
    "Created: / 11-06-2019 / 00:13:00 / Claus Gittinger"
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1258
! !
b1d9b71d6937 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5024
diff changeset
  1259
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1260
!QuadFloat methodsFor:'queries'!
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1261
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1262
isFinite
5194
b4f517f893f1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5075
diff changeset
  1263
    "return true, if the receiver is a finite float (not NaN and not +/-INF)"
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1264
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1265
%{  /* NOCONTEXT */
5016
fe5e7a43b7f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5014
diff changeset
  1266
#ifdef SUPPORT_QUADFLOAT
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1267
    float128_t myVal;
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1268
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1269
    myVal = __quadFloatVal(self);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1270
    RETURN (STX_qisfinite(myVal) ? true : false);
5016
fe5e7a43b7f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5014
diff changeset
  1271
#endif // SUPPORT_QUADFLOAT
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1272
%}.
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1273
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1274
    "
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1275
	1.0 isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1276
	self NaN isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1277
	self infinity isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1278
	self negativeInfinity isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1279
	(0.0 uncheckedDivide: 0.0) isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1280
	(1.0 uncheckedDivide: 0.0) isFinite
5020
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1281
    "
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1282
!
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1283
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1284
isInfinite
5194
b4f517f893f1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5075
diff changeset
  1285
    "return true, if the receiver is an infinite float (+Inf or -Inf)."
5020
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1286
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1287
%{  /* NOCONTEXT */
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1288
#ifdef SUPPORT_QUADFLOAT
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1289
    float128_t myVal;
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1290
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1291
    myVal = __quadFloatVal(self);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1292
    RETURN (STX_qisInf(&myVal) ? true : false);
5020
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1293
#endif // SUPPORT_QUADFLOAT
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1294
%}.
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1295
9d9c46a3c1b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5019
diff changeset
  1296
    "
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1297
	1.0 asQuadFloat isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1298
	1.0 asQuadFloat isInfinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1299
	self NaN isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1300
	self NaN isInfinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1301
	self infinity isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1302
	self infinity isInfinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1303
	self negativeInfinity isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1304
	self negativeInfinity isInfinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1305
	(0.0 uncheckedDivide: 0.0) isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1306
	(1.0 uncheckedDivide: 0.0) isFinite
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1307
    "
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1308
!
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1309
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1310
isNaN
5194
b4f517f893f1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5075
diff changeset
  1311
    "return true, if the receiver is an invalid float (NaN - not a number).
b4f517f893f1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5075
diff changeset
  1312
     These are not created by ST/X float operations (they raise an exception);
b4f517f893f1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5075
diff changeset
  1313
     however, inline C-code could produce them."
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1314
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1315
%{  /* NOCONTEXT */
5016
fe5e7a43b7f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5014
diff changeset
  1316
#ifdef SUPPORT_QUADFLOAT
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1317
    float128_t myVal;
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1318
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1319
    myVal = __quadFloatVal(self);
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1320
    RETURN (STX_qisNan(&myVal) ? true : false);
5016
fe5e7a43b7f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5014
diff changeset
  1321
#endif // SUPPORT_QUADFLOAT
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1322
%}.
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1323
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1324
    "
5267
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1325
	1.0 asQuadFloat isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1326
	self NaN isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1327
	self infinity isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1328
	(0.0 uncheckedDivide: 0.0) isFinite
a9529d2468bb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5266
diff changeset
  1329
	(1.0 uncheckedDivide: 0.0) isFinite
5011
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1330
    "
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1331
! !
889548e8808e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5008
diff changeset
  1332
5266
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1333
!QuadFloat methodsFor:'testing'!
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1334
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1335
isQuadFloat
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1336
    "return true, if the receiver is some kind of quad floating point number (iee quad precision)"
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1337
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1338
    ^ true
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1339
! !
ee57fea3ec72 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5264
diff changeset
  1340
4983
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
!QuadFloat class methodsFor:'documentation'!
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
version_CVS
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
    ^ '$Header$'
696dd6d07736 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
! !
5268
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1346
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1347
d3a464884f60 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 5267
diff changeset
  1348
QuadFloat initialize!