author | Claus Gittinger <cg@exept.de> |
Tue, 20 Jun 2017 18:23:04 +0200 | |
changeset 21869 | 6b8b35c2fe74 |
parent 21868 | f568817ef1d5 |
child 21874 | 6edca189ad56 |
permissions | -rw-r--r-- |
7382 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3 |
All Rights Reserved |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
4 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
5 |
This software is furnished under a license and may be used |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
10 |
hereby transferred. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
11 |
" |
5411 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
17381 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
16 |
LimitedPrecisionReal variableByteSubclass:#LongFloat |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
17 |
instanceVariableNames:'' |
21869 | 18 |
classVariableNames:'DefaultPrintFormat DefaultPrintfFormat LongFloatZero LongFloatOne Pi E Epsilon NaN |
21857 | 19 |
PositiveInfinity NegativeInfinity' |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
20 |
poolDictionaries:'' |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
21 |
category:'Magnitude-Numbers' |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
22 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
23 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
24 |
!LongFloat primitiveDefinitions! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
25 |
%{ |
14743 | 26 |
#include <stdio.h> |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
27 |
#include <errno.h> |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
28 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
29 |
#ifndef __OPTIMIZE__ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
30 |
# define __OPTIMIZE__ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
31 |
#endif |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
32 |
|
4825 | 33 |
#define __USE_ISOC9X 1 |
8980
abee9fcb0385
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
34 |
#define __USE_ISOC99 1 |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
35 |
#include <math.h> |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
36 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
37 |
/* |
19266 | 38 |
* on some systems, errno is a macro ... check for it here |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
39 |
*/ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
40 |
#ifndef errno |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
41 |
extern errno; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
42 |
#endif |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
43 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
44 |
#if !defined (__win32__) |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
45 |
# include <locale.h> |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
46 |
#endif |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
47 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
48 |
#if defined (__aix__) |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
49 |
# include <float.h> |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
50 |
#endif |
4825 | 51 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
52 |
#if defined(__irix__) || defined(__solaris__) || defined(__sunos__) |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
53 |
# include <nan.h> |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
54 |
#endif |
4825 | 55 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
56 |
#if defined(__linux__) |
4825 | 57 |
# ifndef NAN |
5822
4e56f8aadda5
Get nan.h from bits/nan.h for Linux
Stefan Vogel <sv@exept.de>
parents:
5645
diff
changeset
|
58 |
# include <bits/nan.h> |
4825 | 59 |
# endif |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
60 |
#endif |
4825 | 61 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
62 |
#ifdef __win32__ |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
63 |
/* |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
64 |
* no finite(x) ? |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
65 |
* no isnan(x) ? |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
66 |
*/ |
7417 | 67 |
# ifndef isnanl |
68 |
# define isnanl(x) \ |
|
14931 | 69 |
((((unsigned int *)(&x))[0] == 0x00000000) && \ |
70 |
(((unsigned int *)(&x))[1] == 0xC0000000) && \ |
|
71 |
(((unsigned short *)(&x))[4] == 0xFFFF)) |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
72 |
# endif |
7417 | 73 |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
74 |
# ifndef isnan |
7417 | 75 |
# define isnan(x) \ |
14931 | 76 |
((((unsigned int *)(&x))[0] == 0x00000000) && \ |
77 |
(((unsigned int *)(&x))[1] == 0xFFF80000)) |
|
7417 | 78 |
# endif |
79 |
||
80 |
# ifndef isPositiveInfinity |
|
81 |
# define isPositiveInfinity(x) \ |
|
14931 | 82 |
((((unsigned int *)(&x))[0] == 0x00000000) && \ |
83 |
(((unsigned int *)(&x))[1] == 0x7FF00000)) |
|
7417 | 84 |
# endif |
85 |
||
86 |
# ifndef isNegativeInfinity |
|
14931 | 87 |
# define isNegativeInfinity(x) \ |
88 |
((((unsigned int *)(&x))[0] == 0x00000000) && \ |
|
89 |
(((unsigned int *)(&x))[1] == 0xFFF00000)) |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
90 |
# endif |
7417 | 91 |
|
92 |
# ifndef isinf |
|
93 |
# define isinf(x) \ |
|
14931 | 94 |
((((unsigned int *)(&x))[0] == 0x00000000) && \ |
95 |
((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000)) |
|
7417 | 96 |
# endif |
97 |
||
8981
7c7b2a14c8b3
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8980
diff
changeset
|
98 |
# ifndef isfinite |
7c7b2a14c8b3
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8980
diff
changeset
|
99 |
# define isfinite(x) (!isinf(x) && !isnan(x)) |
7417 | 100 |
# endif |
101 |
||
102 |
# define NO_ASINH |
|
103 |
# define NO_ACOSH |
|
104 |
# define NO_ATANH |
|
14931 | 105 |
|
106 |
# ifdef __MINGW__ |
|
107 |
# include <string.h> |
|
19356 | 108 |
|
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
109 |
// sigh: the default ming setup uses the microsoft printf, |
19356 | 110 |
// which does not support long doubles |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
111 |
# define snprintf __mingw_snprintf |
19356 | 112 |
# endif /* __MINGW__ */ |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
113 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
114 |
#endif /* __win32__ */ |
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
115 |
|
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
116 |
#ifdef __solaris__ |
8984 | 117 |
# ifndef isfinite |
118 |
# define isfinite(f) finite((double)(f)) |
|
119 |
# endif |
|
120 |
#endif |
|
121 |
||
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
122 |
#ifdef __realIX__ |
8980
abee9fcb0385
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
123 |
# ifndef isfinite |
abee9fcb0385
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
124 |
# define isfinite(x) 1 |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
125 |
# endif |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
126 |
#endif /* realIX */ |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
127 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
128 |
#if defined(__GNUC__) || defined(__MINGW__) || defined(__win32__) |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
129 |
# define LONGFLOAT long double |
8706 | 130 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
131 |
# if defined(__linux__) || defined(__osx__) || defined(__win32__) |
7397 | 132 |
# define LONG_ceil ceill |
133 |
# define LONG_floor floorl |
|
134 |
# define LONG_sqrt sqrtl |
|
135 |
# define LONG_sin sinl |
|
136 |
# define LONG_cos cosl |
|
137 |
# define LONG_tan tanl |
|
138 |
# define LONG_sinh sinhl |
|
139 |
# define LONG_cosh coshl |
|
140 |
# define LONG_tanh tanhl |
|
141 |
# define LONG_asin asinl |
|
142 |
# define LONG_acos acosl |
|
143 |
# define LONG_atan atanl |
|
144 |
# define LONG_exp expl |
|
145 |
# define LONG_frexp frexpl |
|
146 |
# define LONG_log logl |
|
147 |
# define LONG_log10 log10l |
|
14743 | 148 |
# define LONG_modf modfl |
19323 | 149 |
# define LONG_trunc truncl |
7397 | 150 |
# define LONG_pow powl |
17459 | 151 |
# ifdef __llvm__ |
152 |
# define LONG_isnan isnan |
|
153 |
# else |
|
154 |
# define LONG_isnan isnanl |
|
155 |
# endif |
|
7397 | 156 |
# define LONG_isfinite isfinitel |
15263 | 157 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
158 |
# if !defined(__win32__) |
15263 | 159 |
# define LONG_asinh asinhl |
160 |
# define LONG_acosh acoshl |
|
161 |
# define LONG_atanh atanhl |
|
162 |
# endif /* linux */ |
|
163 |
||
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
164 |
# endif /* defined(__linux__) || defined(__win32__) */ |
8706 | 165 |
|
8981
7c7b2a14c8b3
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8980
diff
changeset
|
166 |
# if !defined(LONG_isnan) |
7c7b2a14c8b3
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8980
diff
changeset
|
167 |
/* This should be true for ISO C99 systems - even for newer linux systems */ |
8706 | 168 |
# define LONG_isnan isnan |
169 |
# define LONG_isfinite isfinite |
|
8982
015dc40e3582
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8981
diff
changeset
|
170 |
# endif /* !defined(LONG_isnan) */ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
171 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
172 |
#endif /* defined(__GNUC__) || defined(__win32__) */ |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
173 |
|
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
174 |
/* |
8706 | 175 |
* on systems which do not support long doubles, fall back to double |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
176 |
* arithmetic |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
177 |
*/ |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
178 |
#ifndef LONGFLOAT |
10333 | 179 |
# define LONGFLOAT double |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
180 |
# define LONGFLOAT_CLASS Float |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
181 |
# define LONGFLOAT_GLOBAL @global(Float) |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
182 |
#else |
10333 | 183 |
# define LONGFLOAT_CLASS LongFloat |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
184 |
# define LONGFLOAT_GLOBAL @global(LongFloat) |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
185 |
#endif |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
186 |
|
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
187 |
struct __longfloatstruct { |
14931 | 188 |
STX_OBJ_HEADER |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
189 |
#ifdef __NEED_DOUBLE_ALIGN |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
190 |
__FILLTYPE_DOUBLE f_filler; |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
191 |
#endif |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
192 |
LONGFLOAT f_longfloatvalue; |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
193 |
}; |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
194 |
|
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
195 |
#define __LongFloatInstPtr(obj) ((struct __longfloatstruct *)(__objPtr(obj))) |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
196 |
|
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
197 |
#ifndef __longFloatVal |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
198 |
# define __longFloatVal(o) \ |
14931 | 199 |
__LongFloatInstPtr(o)->f_longfloatvalue |
4253
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
200 |
#endif |
768802bc61a4
longFloat class falls back to float on systems that do not support them
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
201 |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
202 |
#ifndef __qMKLFLOAT |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
203 |
# define __qMKLFLOAT(__newFloat__, __fVal__) \ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
204 |
{ \ |
14931 | 205 |
__qNew(__newFloat__ , sizeof(struct __longfloatstruct)); \ |
206 |
if (__newFloat__) { \ |
|
207 |
__objPtr(__newFloat__)->o_class = LONGFLOAT_GLOBAL; \ |
|
208 |
__LongFloatInstPtr(__newFloat__)->f_longfloatvalue = (LONGFLOAT)(__fVal__); \ |
|
209 |
} \ |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
210 |
} |
4168 | 211 |
#endif |
212 |
||
213 |
#ifndef __isLongFloat |
|
214 |
# define __isLongFloat(o) \ |
|
14931 | 215 |
(__Class(o) == @global(LongFloat)) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
216 |
#endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
217 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
218 |
#ifndef __qIsLongFloat |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
219 |
# define __qIsLongFloat(o) \ |
14931 | 220 |
(__qClass(o) == @global(LongFloat)) |
4168 | 221 |
#endif |
222 |
||
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
223 |
%} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
224 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
225 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
226 |
!LongFloat class methodsFor:'documentation'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
227 |
|
7382 | 228 |
copyright |
229 |
" |
|
230 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
231 |
All Rights Reserved |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
232 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
233 |
This software is furnished under a license and may be used |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
234 |
only in accordance with the terms of that license and with the |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
235 |
inclusion of the above copyright notice. This software may not |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
236 |
be provided or otherwise made available to, or used by, any |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
237 |
other person. No title to or ownership of the software is |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
238 |
hereby transferred. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
239 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
240 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
241 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
242 |
documentation |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
243 |
" |
7382 | 244 |
LongFloats represent rational numbers with limited precision. |
7380 | 245 |
They use the C-compilers 'long double' format, which is usually |
17219 | 246 |
mapped to the IEEE extended float or IEEE quad float format. |
10333 | 247 |
|
7380 | 248 |
In contrast to Floats (which use the C-compilers 64bit 'double' format), |
7405 | 249 |
LongFloats give you 80 bit floats (extended) or 128 bit floats (quad). |
17129 | 250 |
The actual number of bits depends on the underlying CPU. |
251 |
Thus, code using longFloats is not guaranteed to be portable from one architecture |
|
252 |
to another. |
|
10333 | 253 |
|
13053 | 254 |
NO GARANTY: |
18363 | 255 |
on systems which do not support 'long doubles', LongFloats are (silently) |
256 |
represented as 'doubles'. |
|
10333 | 257 |
|
7380 | 258 |
Representation: |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
259 |
gcc-x86: |
18363 | 260 |
80bit extended IEEE floats stored in in 96bits (12bytes); |
261 |
64 bit mantissa, |
|
262 |
16 bit exponent, |
|
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
263 |
19 decimal digits (approx.) |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
264 |
|
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
265 |
borland-x86 (WIN32): |
18363 | 266 |
80bit extended IEEE floats stored in in 80bits (10bytes); |
267 |
64 bit mantissa, |
|
268 |
16 bit exponent, |
|
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
269 |
19 decimal digits (approx.) |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
270 |
|
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
271 |
gcc-x86_64: (WIN64) |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
272 |
like gcc-x86 |
18363 | 273 |
|
274 |
gcc-sparc: |
|
275 |
128bit quad IEEE floats (16bytes); |
|
276 |
112 bit mantissa, |
|
277 |
16 bit exponent, |
|
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
278 |
34 decimal digits (approx.) |
10333 | 279 |
|
7380 | 280 |
Mixed mode arithmetic: |
18363 | 281 |
longFloat op longFloat -> longFloat |
282 |
longFloat op fix -> longFloat |
|
283 |
longFloat op fraction -> longFloat |
|
284 |
longFloat op integer -> longFloat |
|
285 |
longFloat op shortFloat -> longFloat |
|
286 |
longFloat op float -> longFloat |
|
287 |
longFloat op complex -> complex |
|
10333 | 288 |
|
7405 | 289 |
Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation |
290 |
||
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
291 |
[author:] |
18363 | 292 |
Claus Gittinger |
10333 | 293 |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
294 |
[see also:] |
18363 | 295 |
Number |
296 |
Float ShortFloat Fraction FixedPoint Integer Complex |
|
297 |
FloatArray DoubleArray |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
298 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
299 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
300 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
301 |
!LongFloat class methodsFor:'instance creation'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
302 |
|
7382 | 303 |
basicNew |
304 |
"return a new longFloat - here we return 0.0 |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
305 |
- LongFloats are usually NOT created this way ... |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
306 |
Its implemented here to allow things like binary store & load |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
307 |
of longFloats. (but even this support will go away eventually, its not |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
308 |
a good idea to store the bits of a float - the reader might have a |
10333 | 309 |
totally different representation - so floats will eventually be |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
310 |
binary stored in a device independent format." |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
311 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
312 |
%{ /* NOCONTEXT */ |
18363 | 313 |
#ifdef __SCHTEAM__ |
314 |
return __c__._RETURN( new STDouble(0.0) ); |
|
315 |
#else |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
316 |
OBJ newFloat; |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
317 |
if (sizeof(LONGFLOAT) == sizeof(double)) { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
318 |
__qMKFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
319 |
} else { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
320 |
__qMKLFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
321 |
} |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
322 |
RETURN (newFloat); |
18363 | 323 |
#endif /* not SCHTEAM */ |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
324 |
%} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
325 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
326 |
|
16445 | 327 |
coerce:aNumber |
18833 | 328 |
"convert the argument aNumber into an instance of the receiver's class and return it." |
329 |
||
16445 | 330 |
^ aNumber asLongFloat. |
331 |
! |
|
332 |
||
7382 | 333 |
fromFloat:aFloat |
334 |
"return a new longFloat, given a float value" |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
335 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
336 |
%{ /* NOCONTEXT */ |
18363 | 337 |
#ifdef __SCHTEAM__ |
338 |
if (aFloat.isDouble()) { |
|
339 |
return __c__._RETURN(aFloat); |
|
340 |
} |
|
341 |
if (aFloat.isFloat()) { |
|
342 |
return __c__._RETURN( new STDouble(aFloat.floatValue()) ); |
|
343 |
} |
|
344 |
#else |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
345 |
OBJ newFloat; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
346 |
LONGFLOAT f; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
347 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
348 |
if (sizeof(LONGFLOAT) == sizeof(double)) { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
349 |
RETURN (aFloat); |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
350 |
} |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
351 |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
352 |
if (__isFloatLike(aFloat)) { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
353 |
f = (LONGFLOAT)(__floatVal(aFloat)); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
354 |
__qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
355 |
RETURN (newFloat); |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
356 |
} |
18363 | 357 |
#endif |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
358 |
%}. |
18363 | 359 |
self error:'invalid argument' |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
360 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
361 |
" |
10333 | 362 |
LongFloat fromFloat:123.0 |
363 |
123.0 asLongFloat |
|
364 |
123 asLongFloat |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
365 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
366 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
367 |
|
17219 | 368 |
fromIEEE32Bit: anInteger |
369 |
"creates a long float, given the four native float bytes as an integer" |
|
370 |
||
371 |
%{ /* NOCONTEXT */ |
|
372 |
OBJ newFloat; |
|
373 |
||
374 |
REGISTER union { |
|
18363 | 375 |
unsigned int i; |
376 |
float f; |
|
17219 | 377 |
} r; |
378 |
||
379 |
r.i = __unsignedLongIntVal( anInteger ); |
|
380 |
__qMKLFLOAT(newFloat, r.f); |
|
381 |
RETURN( newFloat ); |
|
18363 | 382 |
%}. |
383 |
^ Float fromIEEE32Bit: anInteger |
|
17219 | 384 |
|
385 |
" |
|
18363 | 386 |
LongFloat fromIEEE32Bit:(ShortFloat pi digitBytesMSB:true) asInteger |
17584 | 387 |
" |
388 |
! |
|
389 |
||
390 |
fromIEEE64Bit: anInteger |
|
391 |
"creates a long double, given the eight native float bytes as an integer" |
|
392 |
||
393 |
%{ /* NOCONTEXT */ |
|
19268 | 394 |
extern int __unsignedLong64IntVal(OBJ o, __uint64__ *pI); |
17584 | 395 |
|
396 |
REGISTER union { |
|
18363 | 397 |
__uint64__ u64; |
398 |
double d; |
|
17584 | 399 |
} r; |
400 |
||
401 |
if (__unsignedLong64IntVal(anInteger, &r.u64)) { |
|
18363 | 402 |
OBJ newFloat; |
403 |
||
404 |
__qMKLFLOAT(newFloat, r.d); |
|
405 |
RETURN( newFloat ); |
|
17584 | 406 |
} |
407 |
%}. |
|
18363 | 408 |
^ Float fromIEEE32Bit: anInteger |
17584 | 409 |
|
410 |
" |
|
18363 | 411 |
LongFloat fromIEEE64Bit:(Float pi digitBytesMSB:true) asInteger |
17219 | 412 |
" |
413 |
! |
|
414 |
||
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
415 |
fromInteger:anInteger |
19360 | 416 |
"return a new longFloat, given an integer value" |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
417 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
418 |
%{ /* NOCONTEXT */ |
18363 | 419 |
#ifdef __SCHTEAM__ |
420 |
if (anInteger.isSmallInteger()) { |
|
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
421 |
return __c__._RETURN( STDouble._new( (double)(anInteger.longValue()) )); |
18363 | 422 |
} |
423 |
#else |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
424 |
OBJ newFloat; |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
425 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
426 |
if (__isSmallInteger(anInteger)) { |
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
427 |
LONGFLOAT f = (LONGFLOAT)__smallIntegerVal(anInteger); |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
428 |
__qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */ |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
429 |
RETURN (newFloat); |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
430 |
} |
18363 | 431 |
#endif /* not SCHTEAM */ |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
432 |
%}. |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
433 |
^ super fromInteger:anInteger |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
434 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
435 |
" |
10333 | 436 |
LongFloat fromInteger:123 |
437 |
LongFloat fromInteger:(100 factorial) |
|
19360 | 438 |
(100 factorial) asLongFloat |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
439 |
" |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
440 |
! |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
441 |
|
17652 | 442 |
fromNumber:aNumber |
443 |
^aNumber asLongFloat |
|
444 |
! |
|
445 |
||
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
446 |
fromShortFloat:aFloat |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
447 |
"return a new longFloat, given a shortFloat value" |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
448 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
449 |
%{ /* NOCONTEXT */ |
18363 | 450 |
#ifdef __SCHTEAM__ |
451 |
if (aFloat.isFloat()) { |
|
452 |
return __c__._RETURN( new STDouble(aFloat.floatValue()) ); |
|
453 |
} |
|
454 |
if (aFloat.isDouble()) { |
|
455 |
return __c__._RETURN( aFloat ); |
|
456 |
} |
|
457 |
#else |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
458 |
OBJ newFloat; |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
459 |
LONGFLOAT f; |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
460 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
461 |
if (__isShortFloat(aFloat)) { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
462 |
f = (LONGFLOAT)(__shortFloatVal(aFloat)); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
463 |
__qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
464 |
RETURN (newFloat); |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
465 |
} |
18363 | 466 |
#endif /* not SCHTEAM */ |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
467 |
%}. |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
468 |
self error:'invalid argumnet' |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
469 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
470 |
" |
10333 | 471 |
LongFloat fromShortFloat:(123.0 asShortFloat) |
472 |
LongFloat fromShortFloat:122 |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
473 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
474 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
475 |
|
12914
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
476 |
!LongFloat class methodsFor:'accessing'! |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
477 |
|
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
478 |
defaultPrintFormat |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
479 |
^ DefaultPrintFormat |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
480 |
! |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
481 |
|
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
482 |
defaultPrintFormat:something |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
483 |
DefaultPrintFormat := something. |
16659 | 484 |
! |
485 |
||
486 |
epsilon |
|
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
487 |
Epsilon isNil ifTrue:[ |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
488 |
Epsilon := self computeEpsilon. |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
489 |
]. |
16662 | 490 |
^ Epsilon |
12914
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
491 |
! ! |
802070da5c65
#printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents:
12476
diff
changeset
|
492 |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
493 |
!LongFloat class methodsFor:'class initialization'! |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
494 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
495 |
initialize |
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
496 |
DefaultPrintFormat := '.19'. "/ 19 valid digits |
21868 | 497 |
DefaultPrintfFormat := '%19f'. |
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
498 |
|
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
499 |
" |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
500 |
self initialize |
10333 | 501 |
" |
502 |
||
503 |
" |
|
504 |
DefaultPrintFormat := '.19'. |
|
505 |
LongFloat pi printString. |
|
506 |
||
507 |
DefaultPrintFormat := '.9'. |
|
508 |
LongFloat pi printString. |
|
509 |
||
510 |
DefaultPrintFormat := '.6'. |
|
511 |
LongFloat pi printString. |
|
7448
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
512 |
" |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
513 |
! ! |
d1aaa52b463e
double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents:
7417
diff
changeset
|
514 |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
515 |
!LongFloat class methodsFor:'constants'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
516 |
|
21857 | 517 |
NaN |
518 |
"return a longFloat which represents not-a-Number (i.e. an invalid number)" |
|
519 |
||
520 |
NaN isNil ifTrue:[ |
|
21868 | 521 |
NaN := super NaN |
21857 | 522 |
]. |
523 |
^ NaN |
|
524 |
||
525 |
" |
|
526 |
LongFloat NaN |
|
527 |
" |
|
528 |
||
529 |
"Created: / 20-06-2017 / 13:52:58 / cg" |
|
530 |
! |
|
531 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
532 |
e |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
533 |
"return the constant e as LongFloat" |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
534 |
|
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
535 |
E isNil ifTrue:[ |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
536 |
"/ enough digits for 128bit IEEE quads |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
537 |
"/ do not write as a literal constant here - we cannot depend on the underlying C-compiler here... |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
538 |
|
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
539 |
E := self readFrom:'2.7182818284590452353602874713526625'. |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
540 |
]. |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
541 |
^ E |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
542 |
! |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
543 |
|
21857 | 544 |
infinity |
545 |
"return a shortFloat which represents positive infinity" |
|
546 |
||
547 |
PositiveInfinity isNil ifTrue:[ |
|
21868 | 548 |
PositiveInfinity := Float infinity asLongFloat |
21857 | 549 |
]. |
550 |
^ PositiveInfinity |
|
551 |
||
552 |
" |
|
553 |
LongFloat infinity |
|
554 |
" |
|
555 |
||
556 |
"Created: / 20-06-2017 / 13:53:45 / cg" |
|
557 |
! |
|
558 |
||
559 |
negativeInfinity |
|
560 |
"return a shortFloat which represents positive infinity" |
|
561 |
||
562 |
NegativeInfinity isNil ifTrue:[ |
|
21868 | 563 |
NegativeInfinity := Float negativeInfinity asLongFloat |
21857 | 564 |
]. |
565 |
^ NegativeInfinity |
|
566 |
||
567 |
" |
|
568 |
LongFloat negativeInfinity |
|
569 |
" |
|
570 |
||
571 |
"Created: / 20-06-2017 / 13:54:19 / cg" |
|
572 |
! |
|
573 |
||
7382 | 574 |
pi |
575 |
"return the constant pi as LongFloat" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
576 |
|
19570
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
577 |
Pi isNil ifTrue:[ |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
578 |
"/ enough digits for 128bit IEEE quads |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
579 |
"/ do not write as a literal constant here - we cannot depend on the underlying C-compiler here... |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
580 |
|
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
581 |
Pi := self readFrom:'3.1415926535897932384626433832795029'. "/ 3.14159265358979323846264338327950288419716939937510582097494459q |
017c53457288
lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents:
19360
diff
changeset
|
582 |
]. |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
583 |
^ Pi |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
584 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
585 |
|
7382 | 586 |
unity |
587 |
"return the neutral element for multiplication (1.0) as LongFloat" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
588 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
589 |
LongFloatOne isNil ifTrue:[ |
7372 | 590 |
LongFloatOne := 1.0 asLongFloat. |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
591 |
]. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
592 |
^ LongFloatOne |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
593 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
594 |
"Modified: 23.4.1996 / 09:26:51 / cg" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
595 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
596 |
|
7382 | 597 |
zero |
598 |
"return the neutral element for addition (0.0) as LongFloat" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
599 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
600 |
LongFloatZero isNil ifTrue:[ |
7372 | 601 |
LongFloatZero := 0.0 asLongFloat |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
602 |
]. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
603 |
^ LongFloatZero |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
604 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
605 |
"Modified: 23.4.1996 / 09:26:45 / cg" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
606 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
607 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
608 |
!LongFloat class methodsFor:'queries'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
609 |
|
21826 | 610 |
defaultPrintPrecision |
611 |
"return the number of decimal digits printed by default" |
|
612 |
||
613 |
^ 8 |
|
614 |
||
615 |
" |
|
21868 | 616 |
ShortFloat defaultPrintPrecision |
617 |
Float defaultPrintPrecision |
|
618 |
LongFloat defaultPrintPrecision |
|
21826 | 619 |
" |
620 |
||
621 |
"Created: / 17-06-2017 / 02:58:42 / cg" |
|
622 |
! |
|
623 |
||
7382 | 624 |
exponentCharacter |
625 |
^ $q |
|
6898 | 626 |
! |
627 |
||
7382 | 628 |
isBuiltInClass |
629 |
"return true if this class is known by the run-time-system. |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
630 |
Here, true is returned for myself, false for subclasses." |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
631 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
632 |
^ self == LongFloat |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
633 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
634 |
"Modified: 23.4.1996 / 16:00:23 / cg" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
635 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
636 |
|
7382 | 637 |
numBitsInExponent |
638 |
"answer the number of bits in the exponent |
|
10333 | 639 |
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused), |
18363 | 640 |
where 15 bits are available in the exponent (i bit is ignored): |
641 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
|
15327 | 642 |
x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused), |
18363 | 643 |
where 15 bits are available in the exponent: |
644 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
|
16780 | 645 |
sparc & others: This is an 128bit longfloat, |
18363 | 646 |
where 15 bits are available in the exponent: |
647 |
00000000 00000000 seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm ... |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
648 |
" |
16780 | 649 |
%{ /* NOCONTEXT */ |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
650 |
#if defined(__x86__) || defined(__x86_64__) |
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
651 |
if (sizeof(LONGFLOAT) == 10) { /* x86 - WIN32: 80bit floats */ |
18363 | 652 |
RETURN (__mkSmallInteger(15)); |
15263 | 653 |
} |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
654 |
if (sizeof(LONGFLOAT) == 12) { /* x86 - some unixes: 96bit floats */ |
18363 | 655 |
RETURN (__mkSmallInteger(15)); |
7413
9c78545361b3
more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents:
7405
diff
changeset
|
656 |
} |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
657 |
if (sizeof(LONGFLOAT) == 16) { /* amd64, x86_64 */ |
18363 | 658 |
RETURN (__mkSmallInteger(15)); |
16780 | 659 |
} |
660 |
#else |
|
15263 | 661 |
if (sizeof(LONGFLOAT) == 16) { |
18363 | 662 |
RETURN (__mkSmallInteger(15)); /* sparc */ |
16780 | 663 |
} |
15263 | 664 |
#endif |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
665 |
%}. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
666 |
"systems without longFloat support use doubles instead" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
667 |
self basicNew basicSize == Float basicNew basicSize ifTrue:[ |
18363 | 668 |
^ Float numBitsInExponent |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
669 |
]. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
670 |
self error:'missing definition' "ifdef missing in above primitive code for this architecture" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
671 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
672 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
673 |
1.0 asLongFloat class numBitsInExponent |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
674 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
675 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
676 |
|
7382 | 677 |
numBitsInIntegerPart |
678 |
"answer the number of bits in the integer part of the mantissa |
|
10333 | 679 |
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused), |
18363 | 680 |
where 1 bit is used for the integer part in the mantissa: |
681 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
|
15327 | 682 |
x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused), |
18363 | 683 |
where 1+63 bits are available in the mantissa: |
684 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
|
16780 | 685 |
sparc & others: This is an 128bit longfloat, |
18363 | 686 |
where 112 bits are available in the mantissa: |
687 |
00000000 00000000 seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm ... |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
688 |
" |
16780 | 689 |
%{ /* NOCONTEXT */ |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
690 |
#if defined(__x86__) || defined(__x86_64__) |
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
691 |
if (sizeof(LONGFLOAT) == 10) { /* x86 - WIN32: 80bit floats */ |
18363 | 692 |
RETURN (__mkSmallInteger(1)); |
15263 | 693 |
} |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
694 |
if (sizeof(LONGFLOAT) == 12) { /* x86 - some other unixes: 96bit floats*/ |
18363 | 695 |
RETURN (__mkSmallInteger(1)); |
7413
9c78545361b3
more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents:
7405
diff
changeset
|
696 |
} |
15263 | 697 |
if (sizeof(LONGFLOAT) == 16) { |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
698 |
RETURN (__mkSmallInteger(1)); /* amd64, x86_64 */ |
16780 | 699 |
} |
15263 | 700 |
#else |
16780 | 701 |
if (sizeof(LONGFLOAT) == 16) { |
18363 | 702 |
RETURN (__mkSmallInteger(0)); /* sparc */ |
16780 | 703 |
} |
15263 | 704 |
#endif |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
705 |
%}. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
706 |
"systems without longFloat support use doubles instead" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
707 |
self basicNew basicSize == Float basicNew basicSize ifTrue:[ |
18363 | 708 |
^ Float numBitsInIntegerPart |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
709 |
]. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
710 |
self error:'missing definition' "ifdef missing in above primitive code for this architecture" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
711 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
712 |
" |
16659 | 713 |
self numBitsInIntegerPart |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
714 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
715 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
716 |
|
7382 | 717 |
numBitsInMantissa |
718 |
"answer the number of bits in the mantissa |
|
10333 | 719 |
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused), |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
720 |
where 1+63 bits are available in the mantissa: |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
721 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
15327 | 722 |
x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused), |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
723 |
where 1+63 bits are available in the mantissa: |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
724 |
00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
10333 | 725 |
sparc: This is an 128bit longfloat, |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
726 |
where 112 bits are available in the mantissa: |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
727 |
00000000 00000000 seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
728 |
" |
16780 | 729 |
%{ /* NOCONTEXT */ |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
730 |
#if defined(__x86__) || defined(__x86_64__) |
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
731 |
if (sizeof(LONGFLOAT) == 10) { /* x86 - WIN32: 80bit */ |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
732 |
RETURN (__mkSmallInteger(64)); |
15263 | 733 |
} |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
734 |
if (sizeof(LONGFLOAT) == 12) { /* x86 some unixes: 96bit */ |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
735 |
RETURN (__mkSmallInteger(64)); |
7413
9c78545361b3
more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents:
7405
diff
changeset
|
736 |
} |
15263 | 737 |
if (sizeof(LONGFLOAT) == 16) { |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
738 |
RETURN (__mkSmallInteger(64)); /* amd64, x86_64 */ |
16780 | 739 |
} |
15263 | 740 |
#else |
16780 | 741 |
if (sizeof(LONGFLOAT) == 16) { |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
742 |
RETURN (__mkSmallInteger(112)); /* sparc */ |
16780 | 743 |
} |
15263 | 744 |
#endif |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
745 |
%}. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
746 |
"systems without longFloat support use doubles instead" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
747 |
self basicNew basicSize == Float basicNew basicSize ifTrue:[ |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
748 |
^ Float numBitsInMantissa |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
749 |
]. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
750 |
self error:'missing definition' "ifdef missing in above primitive code for this architecture" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
751 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
752 |
" |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
753 |
1.0 class numBitsInMantissa |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
754 |
1.0 asShortFloat class numBitsInMantissa |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
755 |
1.0 asLongFloat class numBitsInMantissa |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
756 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
757 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
758 |
|
7382 | 759 |
radix |
760 |
"answer the radix of a LongFloats exponent |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
761 |
This is an IEEE float, which is represented as binary" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
762 |
|
8635 | 763 |
^ 2 "must be careful here, whenever ST/X is used on VAX or a 370" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
764 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
765 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
766 |
!LongFloat methodsFor:'arithmetic'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
767 |
|
7382 | 768 |
* aNumber |
11729 | 769 |
"return the product of the receiver and the argument." |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
770 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
771 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
772 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
773 |
OBJ newFloat; |
10333 | 774 |
LONGFLOAT result, val; |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
775 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
776 |
if (__isSmallInteger(aNumber)) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
777 |
val = (LONGFLOAT)(__intVal(aNumber)); |
10333 | 778 |
doMul: |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
779 |
result = __longFloatVal(self) * val; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
780 |
__qMKLFLOAT(newFloat, result); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
781 |
RETURN ( newFloat ); |
10333 | 782 |
} |
7372 | 783 |
if (aNumber != nil) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
784 |
if (__qIsLongFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
785 |
val = __longFloatVal(aNumber); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
786 |
goto doMul; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
787 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
788 |
if (__qIsFloatLike(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
789 |
val = (LONGFLOAT)(__floatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
790 |
goto doMul; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
791 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
792 |
if (__qIsShortFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
793 |
val = (LONGFLOAT)(__shortFloatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
794 |
goto doMul; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
795 |
} |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
796 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
797 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
798 |
^ aNumber productFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
799 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
800 |
|
7382 | 801 |
+ aNumber |
802 |
"return the sum of the receiver and the argument, aNumber" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
803 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
804 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
805 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
806 |
OBJ newFloat; |
10333 | 807 |
LONGFLOAT result, val; |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
808 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
809 |
if (__isSmallInteger(aNumber)) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
810 |
val = (LONGFLOAT)(__intVal(aNumber)); |
10333 | 811 |
doAdd: |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
812 |
result = __longFloatVal(self) + val; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
813 |
__qMKLFLOAT(newFloat, result); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
814 |
RETURN ( newFloat ); |
10333 | 815 |
} |
7372 | 816 |
if (aNumber != nil) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
817 |
if (__qIsLongFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
818 |
val = __longFloatVal(aNumber); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
819 |
goto doAdd; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
820 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
821 |
if (__qIsFloatLike(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
822 |
val = (LONGFLOAT)(__floatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
823 |
goto doAdd; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
824 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
825 |
if (__qIsShortFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
826 |
val = (LONGFLOAT)(__shortFloatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
827 |
goto doAdd; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
828 |
} |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
829 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
830 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
831 |
^ aNumber sumFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
832 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
833 |
|
7382 | 834 |
- aNumber |
835 |
"return the difference of the receiver and the argument, aNumber" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
836 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
837 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
838 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
839 |
OBJ newFloat; |
10333 | 840 |
LONGFLOAT result, val; |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
841 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
842 |
if (__isSmallInteger(aNumber)) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
843 |
val = (LONGFLOAT)(__intVal(aNumber)); |
10333 | 844 |
doSub: |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
845 |
result = __longFloatVal(self) - val; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
846 |
__qMKLFLOAT(newFloat, result); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
847 |
RETURN ( newFloat ); |
10333 | 848 |
} |
7372 | 849 |
if (aNumber != nil) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
850 |
if (__qIsLongFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
851 |
val = __longFloatVal(aNumber); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
852 |
goto doSub; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
853 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
854 |
if (__qIsFloatLike(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
855 |
val = (LONGFLOAT)(__floatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
856 |
goto doSub; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
857 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
858 |
if (__qIsShortFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
859 |
val = (LONGFLOAT)(__shortFloatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
860 |
goto doSub; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
861 |
} |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
862 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
863 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
864 |
^ aNumber differenceFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
865 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
866 |
|
7382 | 867 |
/ aNumber |
868 |
"return the quotient of the receiver and the argument, aNumber" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
869 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
870 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
871 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
872 |
OBJ newFloat; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
873 |
LONGFLOAT result, val; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
874 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
875 |
if (__isSmallInteger(aNumber)) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
876 |
val = (LONGFLOAT)(__intVal(aNumber)); |
10333 | 877 |
doDiv: |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
878 |
if (val == 0.0) goto badArg; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
879 |
|
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
880 |
result = __longFloatVal(self) / val; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
881 |
__qMKLFLOAT(newFloat, result); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
882 |
RETURN ( newFloat ); |
10333 | 883 |
} |
7372 | 884 |
if (aNumber != nil) { |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
885 |
if (__qIsLongFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
886 |
val = __longFloatVal(aNumber); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
887 |
goto doDiv; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
888 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
889 |
if (__qIsFloatLike(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
890 |
val = (LONGFLOAT)(__floatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
891 |
goto doDiv; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
892 |
} |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
893 |
if (__qIsShortFloat(aNumber)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
894 |
val = (LONGFLOAT)(__shortFloatVal(aNumber)); |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
895 |
goto doDiv; |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
896 |
} |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
897 |
} |
10333 | 898 |
badArg: ; |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
899 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
900 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
901 |
" |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
902 |
No, you shalt not divide by zero |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
903 |
" |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
904 |
^ ZeroDivide raiseRequestWith:thisContext. |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
905 |
]. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
906 |
^ aNumber quotientFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
907 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
908 |
|
14743 | 909 |
abs |
910 |
"return the absolute value of the receiver |
|
911 |
reimplemented here for speed" |
|
912 |
||
913 |
%{ /* NOCONTEXT */ |
|
914 |
||
915 |
OBJ newFloat; |
|
916 |
LONGFLOAT val = __longFloatVal(self); |
|
917 |
||
918 |
if (val < (LONGFLOAT)0.0) { |
|
919 |
__qMKLFLOAT(newFloat, -val); |
|
920 |
RETURN ( newFloat ); |
|
921 |
} |
|
922 |
RETURN (self); |
|
923 |
%}. |
|
924 |
||
925 |
" |
|
926 |
3.0 asLongFloat abs |
|
927 |
-3.0 asLongFloat abs |
|
928 |
" |
|
929 |
! |
|
930 |
||
931 |
negated |
|
932 |
"return myself negated" |
|
933 |
||
934 |
%{ /* NOCONTEXT */ |
|
935 |
OBJ newFloat; |
|
936 |
LONGFLOAT rslt = - __longFloatVal(self); |
|
937 |
||
938 |
__qMKLFLOAT(newFloat, rslt); |
|
939 |
RETURN ( newFloat ); |
|
940 |
%}. |
|
941 |
! |
|
942 |
||
14691 | 943 |
rem: aNumber |
944 |
"return the floating point remainder of the receiver and the argument, aNumber" |
|
945 |
||
946 |
%{ /* NOCONTEXT */ |
|
947 |
||
948 |
/* |
|
949 |
* notice: |
|
950 |
* the following inline code handles some common cases, |
|
951 |
* and exists as an optimization, to speed up those cases. |
|
952 |
* |
|
953 |
* Conceptionally, (and for most other argument types), |
|
954 |
* mixed arithmetic is implemented by double dispatching |
|
955 |
* (see the message send at the bottom) |
|
956 |
*/ |
|
957 |
OBJ newFloat; |
|
958 |
LONGFLOAT result, val; |
|
959 |
||
960 |
if (__isSmallInteger(aNumber)) { |
|
961 |
if (aNumber != __mkSmallInteger(0)) { |
|
962 |
val = (LONGFLOAT)__intVal(aNumber); |
|
963 |
if (val == 0.0) goto badArg; |
|
964 |
computeResult: |
|
965 |
result = fmodl(__longFloatVal(self), val) ; |
|
966 |
__qMKLFLOAT(newFloat, result); |
|
967 |
RETURN ( newFloat ); |
|
968 |
} |
|
969 |
} else if (__isFloatLike(aNumber)) { |
|
970 |
val = (LONGFLOAT)__floatVal(aNumber); |
|
971 |
goto computeResult; |
|
972 |
} else if (__isShortFloat(aNumber)) { |
|
973 |
val = (LONGFLOAT)__shortFloatVal(aNumber); |
|
974 |
goto computeResult; |
|
975 |
} else if (__isLongFloat(aNumber)) { |
|
976 |
val = __longFloatVal(aNumber); |
|
977 |
goto computeResult; |
|
978 |
} |
|
979 |
badArg: ; |
|
980 |
%}. |
|
981 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
982 |
" |
|
983 |
No, you shalt not divide by zero |
|
984 |
" |
|
985 |
^ ZeroDivide raiseRequestWith:thisContext. |
|
986 |
]. |
|
987 |
^ aNumber remainderFromLongFloat:self |
|
988 |
! |
|
989 |
||
7382 | 990 |
uncheckedDivide:aNumber |
991 |
"return the quotient of the receiver and the argument, aNumber. |
|
7471 | 992 |
Do not check for divide by zero (return NaN or Infinity). |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
993 |
This operation is provided for emulators of other languages/semantics, |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
994 |
where no exception is raised for these results (i.e. Java). |
18842 | 995 |
It is only defined if the argument's type is the same as the receiver's." |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
996 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
997 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
998 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
999 |
OBJ newFloat; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1000 |
LONGFLOAT result, val; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1001 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1002 |
if (__isSmallInteger(aNumber)) { |
19266 | 1003 |
val = (LONGFLOAT)(__intVal(aNumber)); |
10333 | 1004 |
doDiv: |
19266 | 1005 |
result = __longFloatVal(self) / val; |
1006 |
__qMKLFLOAT(newFloat, result); |
|
1007 |
RETURN ( newFloat ); |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1008 |
} |
7372 | 1009 |
if (aNumber != nil) { |
19266 | 1010 |
if (__qIsLongFloat(aNumber)) { |
1011 |
val = __longFloatVal(aNumber); |
|
1012 |
goto doDiv; |
|
1013 |
} |
|
1014 |
if (__qIsShortFloat(aNumber)) { |
|
1015 |
val = (LONGFLOAT)(__shortFloatVal(aNumber)); |
|
1016 |
goto doDiv; |
|
1017 |
} |
|
1018 |
if (__qIsFloatLike(aNumber)) { |
|
1019 |
val = (LONGFLOAT)(__floatVal(aNumber)); |
|
1020 |
goto doDiv; |
|
1021 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1022 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1023 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1024 |
^ aNumber quotientFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1025 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1026 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1027 |
0.0 asLongFloat uncheckedDivide:0 |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1028 |
1.0 asLongFloat uncheckedDivide:0.0 |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1029 |
-1.0 asLongFloat uncheckedDivide:0.0 |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1030 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1031 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1032 |
|
5257 | 1033 |
!LongFloat methodsFor:'coercing & converting'! |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1034 |
|
7382 | 1035 |
asFloat |
1036 |
"return a Float with same value as the receiver. |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1037 |
CAVEAT: should raise an error if the receiver exceeds the quadFloat range." |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1038 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1039 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1040 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1041 |
OBJ newFloat; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1042 |
double dVal = (double)__longFloatVal(self); |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1043 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1044 |
__qMKFLOAT(newFloat, dVal); |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1045 |
RETURN ( newFloat ); |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1046 |
%} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1047 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1048 |
" |
10333 | 1049 |
1.0 asLongFloat |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1050 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1051 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1052 |
|
7382 | 1053 |
asInteger |
1054 |
"return an integer with same value - might truncate" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1055 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1056 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1057 |
LONGFLOAT fVal; |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1058 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1059 |
fVal = __longFloatVal(self); |
8980
abee9fcb0385
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
1060 |
if (!LONG_isnan(fVal) && (fVal >= (LONGFLOAT)_MIN_INT) && (fVal <= (LONGFLOAT)_MAX_INT)) { |
10333 | 1061 |
RETURN ( __mkSmallInteger( (INT)fVal) ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1062 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1063 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1064 |
^ super asInteger |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1065 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1066 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1067 |
12345.0 asLongFloat asInteger |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1068 |
1e15 asLongFloat asInteger |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1069 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1070 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1071 |
|
7382 | 1072 |
asLongFloat |
15021 | 1073 |
"return a LongFloat with same value as the receiver - that's me" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1074 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1075 |
^ self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1076 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1077 |
|
7382 | 1078 |
asShortFloat |
1079 |
"return a ShortFloat with same value as the receiver. |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1080 |
CAVEAT: should raise an error if the receiver exceeds the float range." |
4455
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1081 |
|
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1082 |
%{ /* NOCONTEXT */ |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1083 |
|
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1084 |
OBJ newFloat; |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1085 |
float fVal = (float)__longFloatVal(self); |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1086 |
|
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1087 |
__qMKSFLOAT(newFloat, fVal); |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1088 |
RETURN ( newFloat ); |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1089 |
%} |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1090 |
|
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1091 |
" |
10333 | 1092 |
1.0 asLongFloat asShortFloat |
4455
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1093 |
" |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1094 |
! |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4305
diff
changeset
|
1095 |
|
7382 | 1096 |
coerce:aNumber |
18833 | 1097 |
"convert the argument aNumber into an instance of the receiver's class and return it." |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1098 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1099 |
^ aNumber asLongFloat |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1100 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1101 |
|
7382 | 1102 |
generality |
1103 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1104 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1105 |
^ 90 |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1106 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1107 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1108 |
!LongFloat methodsFor:'comparing'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1109 |
|
7382 | 1110 |
< aNumber |
1111 |
"return true, if the argument is greater" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1112 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1113 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1114 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1115 |
if (__isSmallInteger(aNumber)) { |
7372 | 1116 |
RETURN ( (__longFloatVal(self) < (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1117 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1118 |
if (aNumber != nil) { |
7372 | 1119 |
if (__qIsLongFloat(aNumber)) { |
1120 |
RETURN ( (__longFloatVal(self) < __longFloatVal(aNumber)) ? true : false ); |
|
1121 |
} |
|
1122 |
if (__qIsFloatLike(aNumber)) { |
|
1123 |
RETURN ( (__longFloatVal(self) < (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1124 |
} |
|
1125 |
if (__qIsShortFloat(aNumber)) { |
|
1126 |
RETURN ( (__longFloatVal(self) < (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1127 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1128 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1129 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1130 |
^ aNumber lessFromLongFloat:self |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1131 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1132 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1133 |
1.0 asLongFloat > (1/3) |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1134 |
1.0 asLongFloat > (1/3) asLongFloat |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1135 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1136 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1137 |
|
7382 | 1138 |
<= aNumber |
1139 |
"return true, if the argument is greater or equal" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1140 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1141 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1142 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1143 |
if (__isSmallInteger(aNumber)) { |
7372 | 1144 |
RETURN ( (__longFloatVal(self) <= (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1145 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1146 |
if (aNumber != nil) { |
7372 | 1147 |
if (__qIsLongFloat(aNumber)) { |
1148 |
RETURN ( (__longFloatVal(self) <= __longFloatVal(aNumber)) ? true : false ); |
|
1149 |
} |
|
1150 |
if (__qIsFloatLike(aNumber)) { |
|
1151 |
RETURN ( (__longFloatVal(self) <= (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1152 |
} |
|
1153 |
if (__qIsShortFloat(aNumber)) { |
|
1154 |
RETURN ( (__longFloatVal(self) <= (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1155 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1156 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1157 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1158 |
^ self retry:#<= coercing:aNumber |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1159 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1160 |
|
7382 | 1161 |
= aNumber |
1162 |
"return true, if the argument represents the same numeric value |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1163 |
as the receiver, false otherwise" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1164 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1165 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1166 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1167 |
if (__isSmallInteger(aNumber)) { |
7372 | 1168 |
RETURN ( (__longFloatVal(self) == (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1169 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1170 |
if (aNumber != nil) { |
7372 | 1171 |
if (__qIsLongFloat(aNumber)) { |
1172 |
RETURN ( (__longFloatVal(self) == __longFloatVal(aNumber)) ? true : false ); |
|
1173 |
} |
|
1174 |
if (__qIsFloatLike(aNumber)) { |
|
1175 |
RETURN ( (__longFloatVal(self) == (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1176 |
} |
|
1177 |
if (__qIsShortFloat(aNumber)) { |
|
1178 |
RETURN ( (__longFloatVal(self) == (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1179 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1180 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1181 |
%}. |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1182 |
^ aNumber equalFromLongFloat:self |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1183 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1184 |
|
7382 | 1185 |
> aNumber |
1186 |
"return true, if the argument is less" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1187 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1188 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1189 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1190 |
if (__isSmallInteger(aNumber)) { |
7372 | 1191 |
RETURN ( (__longFloatVal(self) > (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1192 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1193 |
if (aNumber != nil) { |
7372 | 1194 |
if (__qIsLongFloat(aNumber)) { |
1195 |
RETURN ( (__longFloatVal(self) > __longFloatVal(aNumber)) ? true : false ); |
|
1196 |
} |
|
1197 |
if (__qIsFloatLike(aNumber)) { |
|
1198 |
RETURN ( (__longFloatVal(self) > (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1199 |
} |
|
1200 |
if (__qIsShortFloat(aNumber)) { |
|
1201 |
RETURN ( (__longFloatVal(self) > (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1202 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1203 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1204 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1205 |
^ self retry:#> coercing:aNumber |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1206 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1207 |
|
7382 | 1208 |
>= aNumber |
1209 |
"return true, if the argument is less or equal" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1210 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1211 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1212 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1213 |
if (__isSmallInteger(aNumber)) { |
7372 | 1214 |
RETURN ( (__longFloatVal(self) >= (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1215 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1216 |
if (aNumber != nil) { |
7372 | 1217 |
if (__qIsLongFloat(aNumber)) { |
1218 |
RETURN ( (__longFloatVal(self) >= __longFloatVal(aNumber)) ? true : false ); |
|
1219 |
} |
|
1220 |
if (__qIsFloatLike(aNumber)) { |
|
1221 |
RETURN ( (__longFloatVal(self) >= (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1222 |
} |
|
1223 |
if (__qIsShortFloat(aNumber)) { |
|
1224 |
RETURN ( (__longFloatVal(self) >= (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1225 |
} |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1226 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1227 |
%}. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1228 |
^ self retry:#>= coercing:aNumber |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1229 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1230 |
|
7382 | 1231 |
hash |
1232 |
"return a number for hashing; redefined, since floats compare |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1233 |
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1234 |
as 3 hash." |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1235 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1236 |
|i| |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1237 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1238 |
(self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
7372 | 1239 |
i := self asInteger. |
1240 |
self = i ifTrue:[ |
|
1241 |
^ i hash |
|
1242 |
]. |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1243 |
]. |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1244 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1245 |
^ self asFloat hash |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1246 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1247 |
" |
10333 | 1248 |
1.2345 hash |
1249 |
1.2345 asLongFloat hash |
|
1250 |
1 hash |
|
1251 |
1.0 hash |
|
1252 |
1.0 asLongFloat hash |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1253 |
" |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1254 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1255 |
|
7382 | 1256 |
~= aNumber |
1257 |
"return true, if the arguments value are not equal." |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1258 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1259 |
%{ /* NOCONTEXT */ |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1260 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1261 |
if (__isSmallInteger(aNumber)) { |
7372 | 1262 |
RETURN ( (__longFloatVal(self) != (LONGFLOAT)(__intVal(aNumber))) ? true : false ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1263 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1264 |
if (aNumber != nil) { |
7372 | 1265 |
if (__isLongFloat(aNumber)) { |
1266 |
RETURN ( (__longFloatVal(self) != __longFloatVal(aNumber)) ? true : false ); |
|
1267 |
} |
|
1268 |
if (__qIsFloatLike(aNumber)) { |
|
1269 |
RETURN ( (__longFloatVal(self) != (LONGFLOAT)(__floatVal(aNumber))) ? true : false ); |
|
1270 |
} |
|
1271 |
if (__qIsShortFloat(aNumber)) { |
|
1272 |
RETURN ( (__longFloatVal(self) != (LONGFLOAT)(__shortFloatVal(aNumber))) ? true : false ); |
|
1273 |
} |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1274 |
} else { |
7372 | 1275 |
RETURN ( true ); |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1276 |
} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1277 |
%}. |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1278 |
^ super ~= aNumber |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1279 |
! ! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1280 |
|
10319 | 1281 |
!LongFloat methodsFor:'double dispatching'! |
1282 |
||
1283 |
productFromInteger:anInteger |
|
1284 |
"sent when an integer does not know how to multiply the receiver, a float" |
|
1285 |
||
1286 |
%{ /* NOCONTEXT */ |
|
1287 |
||
1288 |
OBJ newFloat; |
|
1289 |
LONGFLOAT result; |
|
1290 |
||
1291 |
if (__isSmallInteger(anInteger)) { |
|
10333 | 1292 |
result = __longFloatVal(self) * (LONGFLOAT)(__intVal(anInteger)); |
10319 | 1293 |
retResult: |
10333 | 1294 |
__qMKLFLOAT(newFloat, result); |
1295 |
RETURN ( newFloat ); |
|
1296 |
} |
|
10319 | 1297 |
%}. |
1298 |
^ super productFromInteger:anInteger |
|
1299 |
! |
|
1300 |
||
1301 |
sumFromInteger:anInteger |
|
1302 |
"sent when an integer does not know how to add the receiver, a float" |
|
1303 |
||
1304 |
%{ /* NOCONTEXT */ |
|
1305 |
||
1306 |
OBJ newFloat; |
|
1307 |
LONGFLOAT result; |
|
1308 |
||
1309 |
if (__isSmallInteger(anInteger)) { |
|
10333 | 1310 |
result = __longFloatVal(self) + (LONGFLOAT)(__intVal(anInteger)); |
10319 | 1311 |
retResult: |
10333 | 1312 |
__qMKLFLOAT(newFloat, result); |
1313 |
RETURN ( newFloat ); |
|
1314 |
} |
|
10319 | 1315 |
%}. |
1316 |
^ super sumFromInteger:anInteger |
|
1317 |
! ! |
|
1318 |
||
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1319 |
!LongFloat methodsFor:'mathematical functions'! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1320 |
|
7382 | 1321 |
exp |
1322 |
"return e raised to the power of the receiver" |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1323 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1324 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1325 |
|
10333 | 1326 |
%{ |
7374 | 1327 |
#if defined(LONG_exp) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1328 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1329 |
LONGFLOAT rslt; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1330 |
OBJ newFloat; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1331 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1332 |
__threadErrno = 0; |
7374 | 1333 |
rslt = LONG_exp(__longFloatVal(self)); |
7383 | 1334 |
# ifdef LONG_isnan |
1335 |
if (! LONG_isnan(rslt)) |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1336 |
# endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1337 |
if (__threadErrno == 0) { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1338 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1339 |
RETURN ( newFloat ); |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1340 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1341 |
#else |
7395 | 1342 |
useFallBack = true; |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1343 |
#endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1344 |
%}. |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1345 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1346 |
^ super exp |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1347 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1348 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1349 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1350 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1351 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1352 |
selector:#exp |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1353 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1354 |
errorString:'bad receiver in exp' |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1355 |
! |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1356 |
|
7382 | 1357 |
ln |
1358 |
"return the natural logarithm of myself. |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1359 |
Raises an exception, if the receiver is less or equal to zero." |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1360 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1361 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1362 |
|
10333 | 1363 |
%{ |
7374 | 1364 |
#if defined(LONG_log) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1365 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1366 |
LONGFLOAT val, rslt; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1367 |
OBJ newFloat; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1368 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1369 |
val = __longFloatVal(self); |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1370 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
1371 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1372 |
if (val > 0.0) |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1373 |
# endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1374 |
{ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1375 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1376 |
rslt = LONG_log(val); |
7382 | 1377 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1378 |
if (! LONG_isnan(rslt)) |
7372 | 1379 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1380 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1381 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1382 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1383 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1384 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1385 |
} |
7372 | 1386 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1387 |
#else |
7395 | 1388 |
useFallBack = true; |
7372 | 1389 |
#endif |
1390 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1391 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1392 |
^ super ln |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1393 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1394 |
|
7372 | 1395 |
" |
1396 |
an invalid value for logarithm |
|
1397 |
" |
|
1398 |
^ self class |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1399 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1400 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1401 |
selector:#ln |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1402 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1403 |
errorString:'bad receiver in ln' |
7372 | 1404 |
! |
1405 |
||
1406 |
log10 |
|
21826 | 1407 |
"return the base-10 logarithm of the receiver. |
7372 | 1408 |
Raises an exception, if the receiver is less or equal to zero." |
1409 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1410 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1411 |
|
10333 | 1412 |
%{ |
7374 | 1413 |
#if defined(LONG_log10) |
7372 | 1414 |
|
1415 |
LONGFLOAT val, rslt; |
|
1416 |
OBJ newFloat; |
|
1417 |
||
1418 |
val = __longFloatVal(self); |
|
1419 |
||
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
1420 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7372 | 1421 |
if (val > 0.0) |
1422 |
# endif |
|
1423 |
{ |
|
21868 | 1424 |
__threadErrno = 0; |
1425 |
rslt = LONG_log10(val); |
|
7382 | 1426 |
# ifdef LONG_isnan |
21868 | 1427 |
if (! LONG_isnan(rslt)) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1428 |
# endif |
21868 | 1429 |
{ |
1430 |
if (__threadErrno == 0) { |
|
1431 |
__qMKLFLOAT(newFloat, rslt); |
|
1432 |
RETURN ( newFloat ); |
|
1433 |
} |
|
1434 |
} |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1435 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1436 |
#else |
7395 | 1437 |
useFallBack = true; |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1438 |
#endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1439 |
%}. |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1440 |
useFallBack notNil ifTrue:[ |
21868 | 1441 |
^ super log10 |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1442 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1443 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1444 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1445 |
an invalid value for logarithm |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1446 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1447 |
^ self class |
21868 | 1448 |
raise:#domainErrorSignal |
1449 |
receiver:self |
|
1450 |
selector:#log10 |
|
1451 |
arguments:#() |
|
1452 |
errorString:'bad receiver in log10' |
|
21826 | 1453 |
|
1454 |
"Modified (comment): / 16-06-2017 / 10:42:30 / cg" |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1455 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1456 |
|
7382 | 1457 |
raisedTo:aNumber |
1458 |
"return self raised to the power of aNumber" |
|
1459 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1460 |
|n useFallBack| |
7382 | 1461 |
|
1462 |
n := aNumber asFloat. |
|
1463 |
%{ |
|
1464 |
#if defined(LONG_pow) |
|
1465 |
LONGFLOAT rslt; |
|
1466 |
OBJ newFloat; |
|
1467 |
||
1468 |
if (__isFloatLike(n)) { |
|
19266 | 1469 |
__threadErrno = 0; |
1470 |
rslt = LONG_pow(__longFloatVal(self), __floatVal(n)); |
|
7382 | 1471 |
# ifdef LONG_isnan |
19266 | 1472 |
if (! LONG_isnan(rslt)) |
7382 | 1473 |
# endif |
19266 | 1474 |
{ |
1475 |
if (__threadErrno == 0) { |
|
1476 |
__qMKLFLOAT(newFloat, rslt); |
|
1477 |
RETURN ( newFloat ); |
|
1478 |
} |
|
1479 |
} |
|
7382 | 1480 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1481 |
#else |
7395 | 1482 |
useFallBack = true; |
7382 | 1483 |
#endif |
1484 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1485 |
useFallBack notNil ifTrue:[ |
19266 | 1486 |
^ super raisedTo:aNumber |
19090 | 1487 |
]. |
1488 |
||
1489 |
"/ the c-library pow functin, has a bug: |
|
19266 | 1490 |
"/ it does not deal correctly with negative numbers. |
19090 | 1491 |
"/ I.e. it raises an error on -8^(1/3) instead of returning a negative -2 |
1492 |
"/ work around with a kludge: |
|
1493 |
self < 0 ifTrue:[ |
|
19266 | 1494 |
^ (self negated raisedTo:n) negated |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1495 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1496 |
|
7382 | 1497 |
" |
1498 |
an invalid argument (not convertable to float ?) |
|
1499 |
" |
|
1500 |
^ self class |
|
19266 | 1501 |
raise:#domainErrorSignal |
1502 |
receiver:self |
|
1503 |
selector:#raisedTo: |
|
1504 |
arguments:(Array with:aNumber) |
|
1505 |
errorString:'bad receiver/arg in raisedTo:' |
|
7382 | 1506 |
|
1507 |
"Modified: / 16.11.2001 / 14:16:51 / cg" |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1508 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1509 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1510 |
sqrt |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1511 |
"return the square root of myself. |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1512 |
Raises an exception, if the receiver is less than zero." |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1513 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1514 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1515 |
|
10333 | 1516 |
%{ |
7374 | 1517 |
#if defined(LONG_sqrt) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1518 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1519 |
LONGFLOAT val, rslt; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1520 |
OBJ newFloat; |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1521 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1522 |
val = __longFloatVal(self); |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1523 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
1524 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1525 |
if (val >= 0.0) |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1526 |
# endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1527 |
{ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1528 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1529 |
rslt = LONG_sqrt(val); |
7382 | 1530 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1531 |
if (! LONG_isnan(rslt)) |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1532 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1533 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1534 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1535 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1536 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1537 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1538 |
} |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1539 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1540 |
#else |
7395 | 1541 |
useFallBack = true; |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1542 |
#endif |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1543 |
%}. |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1544 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1545 |
^ super sqrt |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1546 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1547 |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1548 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1549 |
raise:#imaginaryResultSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1550 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1551 |
selector:#sqrt |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1552 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1553 |
errorString:'bad (negative) receiver in sqrt' |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1554 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1555 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1556 |
10 asLongFloat sqrt |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1557 |
-10 asLongFloat sqrt |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1558 |
" |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1559 |
|
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1560 |
"Modified: / 16.11.2001 / 14:14:43 / cg" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1561 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1562 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1563 |
!LongFloat methodsFor:'printing & storing'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1564 |
|
7382 | 1565 |
printString |
1566 |
"return a printed representation of the receiver |
|
1567 |
LimitedPrecisonReal and its subclasses use #printString instead of |
|
1568 |
#printOn: as basic print mechanism." |
|
1569 |
||
18137 | 1570 |
^ self printStringWithFormat:DefaultPrintFormat |
1571 |
||
1572 |
" |
|
18363 | 1573 |
LongFloat pi printString. |
1574 |
1.234 asLongFloat printString. |
|
1575 |
1.0 asLongFloat printString. |
|
1576 |
1e10 asLongFloat printString. |
|
1577 |
1.2e3 asLongFloat printString. |
|
1578 |
1.2e30 asLongFloat printString. |
|
1579 |
(1.0 uncheckedDivide:0) asLongFloat printString. |
|
1580 |
(0.0 uncheckedDivide:0) asLongFloat printString. |
|
1581 |
self pi printString. |
|
1582 |
||
1583 |
DecimalPointCharacterForPrinting := $,. |
|
1584 |
1.234 asLongFloat printString. |
|
1585 |
1.0 asLongFloat printString. |
|
1586 |
1e10 asLongFloat printString. |
|
1587 |
1.2e3 asLongFloat printString. |
|
1588 |
1.2e30 asLongFloat printString. |
|
1589 |
(1.0 uncheckedDivide:0) asLongFloat printString. |
|
1590 |
(0.0 uncheckedDivide:0) asLongFloat printString. |
|
1591 |
DecimalPointCharacterForPrinting := $. |
|
18137 | 1592 |
" |
1593 |
! |
|
1594 |
||
1595 |
printStringWithFormat:format |
|
1596 |
"return a printed representation of the receiver; |
|
1597 |
fmt must be of the form: .nn, where nn is the number of digits. |
|
1598 |
To print 6 valid digits, use printStringWithFormat:'.6' |
|
1599 |
For Floats, the default used in printString, is 15 (because its a double); |
|
1600 |
for ShortFloats, it is 6 (because it is a float)" |
|
1601 |
||
7382 | 1602 |
%{ /* NOCONTEXT */ |
1603 |
||
1604 |
char buffer[64]; |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1605 |
char fmtBuffer[20]; |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1606 |
char *fmt; |
7382 | 1607 |
REGISTER char *cp; |
1608 |
OBJ s; |
|
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1609 |
int len ; |
7382 | 1610 |
|
18137 | 1611 |
if (__isStringLike(format)) { |
18363 | 1612 |
fmt = (char *) __stringVal(format); |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1613 |
} else { |
18363 | 1614 |
fmt = ".19"; |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1615 |
} |
7382 | 1616 |
/* |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1617 |
* build a printf format string |
7382 | 1618 |
*/ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1619 |
fmtBuffer[0] = '%'; |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1620 |
strncpy(fmtBuffer+1, fmt, 10); |
7382 | 1621 |
if (sizeof(LONGFLOAT) == sizeof(double)) { |
1622 |
#ifdef SYSV |
|
18363 | 1623 |
strcat(fmtBuffer, "lg"); |
7382 | 1624 |
#else |
18363 | 1625 |
strcat(fmtBuffer, "G"); |
7382 | 1626 |
#endif |
1627 |
} else { |
|
18363 | 1628 |
strcat(fmtBuffer, "LG"); |
7382 | 1629 |
} |
1630 |
||
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1631 |
/* |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1632 |
* actually only needed on sparc: since thisContext is |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1633 |
* in a global register, which gets destroyed by printf, |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1634 |
* manually save it here - very stupid ... |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1635 |
*/ |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1636 |
__BEGIN_PROTECT_REGISTERS__ |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1637 |
len = snprintf(buffer, sizeof(buffer), fmtBuffer, __longFloatVal(self)); |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1638 |
__END_PROTECT_REGISTERS__ |
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1639 |
|
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1640 |
if (len >= 0 && len < sizeof(buffer)-3) { |
18363 | 1641 |
/* |
1642 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
|
1643 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
|
1644 |
*/ |
|
1645 |
for (cp = buffer; *cp; cp++) { |
|
1646 |
if ((*cp == '.') || (*cp == ',') || (*cp == 'E') || (*cp == 'e')) break; |
|
1647 |
} |
|
1648 |
if (!*cp && (cp[-1] >= '0') && (cp[-1] <= '9')) { |
|
1649 |
if (__isCharacter(@global(DecimalPointCharacterForPrinting))) { |
|
1650 |
*cp++ = __intVal(__characterVal(@global(DecimalPointCharacterForPrinting))); |
|
1651 |
} else { |
|
1652 |
*cp++ = '.'; |
|
1653 |
} |
|
1654 |
*cp++ = '0'; |
|
1655 |
*cp = '\0'; |
|
1656 |
} else { |
|
1657 |
if (cp && (*cp == '.')) { |
|
1658 |
if (__isCharacter(@global(DecimalPointCharacterForPrinting))) { |
|
1659 |
*cp = __intVal(__characterVal(@global(DecimalPointCharacterForPrinting))); |
|
1660 |
} |
|
1661 |
} |
|
1662 |
} |
|
1663 |
||
1664 |
s = __MKSTRING(buffer); |
|
1665 |
if (s != nil) { |
|
1666 |
RETURN (s); |
|
1667 |
} |
|
7382 | 1668 |
} |
1669 |
%}. |
|
1670 |
" |
|
1671 |
memory allocation (for the new string) failed. |
|
1672 |
When we arrive here, there was no memory, even after a garbage collect. |
|
1673 |
This means, that the VM wanted to get some more memory from the |
|
1674 |
OS, which was not kind enough to give it. |
|
1675 |
Bad luck - you should increase the swap space on your machine. |
|
1676 |
" |
|
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1677 |
^ AllocationFailure raise. |
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1678 |
|
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1679 |
" |
18363 | 1680 |
1.234 asLongFloat printString. |
1681 |
1.0 asLongFloat printString. |
|
1682 |
1e10 asLongFloat printString. |
|
1683 |
1.2e3 asLongFloat printString. |
|
1684 |
1.2e30 asLongFloat printString. |
|
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
1685 |
(1.0 uncheckedDivide:0) isInfinite. |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
1686 |
(0.0 uncheckedDivide:0) isNaN. |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
1687 |
(1.0 uncheckedDivide:0) asLongFloat isInfinite. |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
1688 |
(0.0 uncheckedDivide:0) asLongFloat isNaN. |
18363 | 1689 |
(1.0 uncheckedDivide:0) asLongFloat printString. |
1690 |
(0.0 uncheckedDivide:0) asLongFloat printString. |
|
1691 |
self pi printString. |
|
1692 |
||
1693 |
DecimalPointCharacterForPrinting := $,. |
|
1694 |
1.234 asLongFloat printString. |
|
1695 |
1.0 asLongFloat printString. |
|
1696 |
1e10 asLongFloat printString. |
|
1697 |
1.2e3 asLongFloat printString. |
|
1698 |
1.2e30 asLongFloat printString. |
|
1699 |
(1.0 uncheckedDivide:0) asLongFloat printString. |
|
1700 |
(0.0 uncheckedDivide:0) asLongFloat printString. |
|
1701 |
DecimalPointCharacterForPrinting := $. |
|
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1702 |
" |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
1703 |
! |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1704 |
|
7382 | 1705 |
printfPrintString:formatString |
7746 | 1706 |
"non-standard: return a printed representation of the receiver |
7382 | 1707 |
as specified by formatString, which is defined by printf. |
1708 |
If you use this, be aware, that specifying long doubles differs on |
|
10333 | 1709 |
systems; on Linux/gnuc machines you have to give something like %LF/%LG. |
7382 | 1710 |
Also, the resulting string may not be longer than 255 bytes - |
20419 | 1711 |
since that's the (static) size of the buffer. |
11925
6c93ef7cb9ff
changed #printfPrintString:
Claus Gittinger <cg@exept.de>
parents:
11729
diff
changeset
|
1712 |
This method is NONSTANDARD and may be removed without notice. |
6c93ef7cb9ff
changed #printfPrintString:
Claus Gittinger <cg@exept.de>
parents:
11729
diff
changeset
|
1713 |
WARNNG: this goes directly to the C-printf function and may therefore me inherently unsafe. |
6c93ef7cb9ff
changed #printfPrintString:
Claus Gittinger <cg@exept.de>
parents:
11729
diff
changeset
|
1714 |
Please use the printf: method, which is safe as it is completely implemented in Smalltalk." |
7382 | 1715 |
|
1716 |
%{ /* STACK: 400 */ |
|
1717 |
char buffer[256]; |
|
1718 |
OBJ s; |
|
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1719 |
int len; |
7382 | 1720 |
|
12476
66b5104cedc9
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11925
diff
changeset
|
1721 |
if (__isStringLike(formatString)) { |
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1722 |
/* |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1723 |
* actually only needed on sparc: since thisContext is |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1724 |
* in a global register, which gets destroyed by printf, |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1725 |
* manually save it here - very stupid ... |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1726 |
*/ |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1727 |
__BEGIN_PROTECT_REGISTERS__ |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1728 |
|
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1729 |
len = snprintf(buffer, sizeof(buffer), __stringVal(formatString), __longFloatVal(self)); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1730 |
|
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1731 |
__END_PROTECT_REGISTERS__ |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1732 |
|
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1733 |
if (len < 0) goto fail; |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1734 |
|
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1735 |
s = __MKSTRING_L(buffer, len); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1736 |
if (s != nil) { |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1737 |
RETURN (s); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1738 |
} |
7382 | 1739 |
} |
8417
dcba76518224
Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents:
7831
diff
changeset
|
1740 |
fail: ; |
7382 | 1741 |
%}. |
1742 |
self primitiveFailed |
|
1743 |
||
1744 |
" |
|
10333 | 1745 |
Float pi asLongFloat printfPrintString:'%%LG -> %LG' |
1746 |
Float pi asLongFloat printfPrintString:'%%LF -> %LF' |
|
1747 |
Float pi asLongFloat printfPrintString:'%%7.15LG -> %7.15LG' |
|
1748 |
Float pi asLongFloat printfPrintString:'%%7.15LF -> %7.15LF' |
|
7382 | 1749 |
" |
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1750 |
! |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1751 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1752 |
storeString |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1753 |
"return a printed representation of the receiver; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1754 |
all valid digits are printed. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1755 |
LimitedPrecisonReal and its subclasses use #storeString instead of |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1756 |
#storeOn: as basic print mechanism." |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1757 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1758 |
%{ /* NOCONTEXT */ |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1759 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1760 |
char buffer[64]; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1761 |
REGISTER char *cp; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1762 |
OBJ s; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1763 |
int len; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1764 |
char *fmtBuffer; |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1765 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1766 |
/* |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1767 |
* build a printf format string |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1768 |
*/ |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1769 |
if (sizeof(LONGFLOAT) == sizeof(double)) { |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1770 |
#ifdef SYSV |
18363 | 1771 |
fmtBuffer = "%.17lg"; |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1772 |
#else |
18363 | 1773 |
fmtBuffer = "%.17G"; |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1774 |
#endif |
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1775 |
} else { |
18363 | 1776 |
fmtBuffer = "%.20LG"; |
14673
d3c91be01e96
setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents:
14600
diff
changeset
|
1777 |
} |
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1778 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1779 |
__BEGIN_PROTECT_REGISTERS__ |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1780 |
len = snprintf(buffer, sizeof(buffer), fmtBuffer, __longFloatVal(self)); |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1781 |
__END_PROTECT_REGISTERS__ |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1782 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1783 |
if (len >= 0 && len < sizeof(buffer)-3) { |
18363 | 1784 |
/* |
1785 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
|
1786 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
|
1787 |
*/ |
|
1788 |
for (cp = buffer; *cp; cp++) { |
|
1789 |
if ((*cp == '.') || (*cp == ',') || (*cp == 'E') || (*cp == 'e')) break; |
|
1790 |
} |
|
1791 |
if (!*cp && (cp[-1] >= '0') && (cp[-1] <= '9')) { |
|
1792 |
*cp++ = '.'; |
|
1793 |
*cp++ = '0'; |
|
1794 |
*cp = '\0'; |
|
1795 |
} |
|
1796 |
||
1797 |
s = __MKSTRING(buffer); |
|
1798 |
if (s != nil) { |
|
1799 |
RETURN (s); |
|
1800 |
} |
|
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1801 |
} |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1802 |
%}. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1803 |
" |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1804 |
memory allocation (for the new string) failed. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1805 |
When we arrive here, there was no memory, even after a garbage collect. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1806 |
This means, that the VM wanted to get some more memory from the |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1807 |
OS, which was not kind enough to give it. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1808 |
Bad luck - you should increase the swap space on your machine. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1809 |
" |
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
20419
diff
changeset
|
1810 |
^ AllocationFailure raise. |
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1811 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1812 |
" |
18363 | 1813 |
1.0 asLongFloat storeString |
1814 |
1.234 asLongFloat storeString |
|
1815 |
1e10 asLongFloat storeString |
|
1816 |
1.2e3 asLongFloat storeString |
|
1817 |
1.2e30 asLongFloat storeString |
|
1818 |
LongFloat pi asLongFloat storeString |
|
1819 |
(1.0 uncheckedDivide:0) asLongFloat storeString |
|
1820 |
(0.0 uncheckedDivide:0) asLongFloat storeString |
|
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1821 |
|
9122
858a4118a135
comment; decimalPoint classVars renamed
Claus Gittinger <cg@exept.de>
parents:
8984
diff
changeset
|
1822 |
notice that the storeString is NOT affected by DecimalPointCharacterForPrinting: |
858a4118a135
comment; decimalPoint classVars renamed
Claus Gittinger <cg@exept.de>
parents:
8984
diff
changeset
|
1823 |
|
18363 | 1824 |
DecimalPointCharacterForPrinting := $,. |
1825 |
1.234 asLongFloat storeString. |
|
1826 |
1.0 asLongFloat storeString. |
|
1827 |
1e10 asLongFloat storeString. |
|
1828 |
1.2e3 asLongFloat storeString. |
|
1829 |
1.2e30 asLongFloat storeString. |
|
1830 |
(1.0 uncheckedDivide:0) asLongFloat storeString. |
|
1831 |
(0.0 uncheckedDivide:0) asLongFloat storeString. |
|
1832 |
DecimalPointCharacterForPrinting := $. |
|
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8417
diff
changeset
|
1833 |
" |
5885
91ff479e693b
added #defaultNumberOfDigits
Claus Gittinger <cg@exept.de>
parents:
5822
diff
changeset
|
1834 |
! ! |
91ff479e693b
added #defaultNumberOfDigits
Claus Gittinger <cg@exept.de>
parents:
5822
diff
changeset
|
1835 |
|
7415 | 1836 |
!LongFloat methodsFor:'private-accessing'! |
1837 |
||
1838 |
basicAt:index |
|
1839 |
"return an internal byte of the float. |
|
1840 |
The value returned here depends on byte order, float representation etc. |
|
1841 |
Therefore, this method should be used strictly private. |
|
1842 |
||
10333 | 1843 |
Notice: |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1844 |
the need to redefine this method here is due to the |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1845 |
inability of many machines to store floats in non-double aligned memory. |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1846 |
Therefore, on some machines, the first <nPad> bytes of a float are left unused, |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1847 |
and the actual float is stored at index <nPad>+1 ... |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1848 |
To hide this at one place, this method knows about that, and returns |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1849 |
values as if this filler wasnt present." |
7415 | 1850 |
|
1851 |
%{ /* NOCONTEXT */ |
|
1852 |
||
1853 |
register int indx; |
|
1854 |
unsigned char *cp; |
|
1855 |
||
1856 |
/* |
|
1857 |
* notice the missing test for self being a nonNilObject - |
|
1858 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1859 |
* and SmallInteger |
|
1860 |
*/ |
|
1861 |
if (__isSmallInteger(index)) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1862 |
indx = __intVal(index) - 1; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1863 |
if (((unsigned)(indx)) < sizeof(LONGFLOAT)) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1864 |
cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue)); |
8913 | 1865 |
RETURN ( __mkSmallInteger(cp[indx] & 0xFF) ); |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1866 |
} |
7415 | 1867 |
} |
1868 |
%}. |
|
1869 |
^ self indexNotIntegerOrOutOfBounds:index |
|
1870 |
! |
|
1871 |
||
1872 |
basicAt:index put:value |
|
1873 |
"set an internal byte of the float. |
|
1874 |
The value to be stored here depends on byte order, float representation etc. |
|
1875 |
Therefore, this method should be used strictly private. |
|
1876 |
||
10333 | 1877 |
Notice: |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1878 |
the need to redefine this method here is due to the |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1879 |
inability of many machines to store floats in non-double aligned memory. |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1880 |
Therefore, on some machines, the first <nPad> bytes of a float are left unused, |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1881 |
and the actual float is stored at index <nPad>+1 .. . |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1882 |
To hide this at one place, this method knows about that, and returns |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1883 |
values as if this filler wasnt present." |
7415 | 1884 |
|
1885 |
%{ /* NOCONTEXT */ |
|
1886 |
register int indx, val; |
|
1887 |
unsigned char *cp; |
|
1888 |
||
1889 |
/* |
|
1890 |
* notice the missing test for self being a nonNilObject - |
|
1891 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1892 |
* and SmallInteger |
|
1893 |
*/ |
|
1894 |
if (__bothSmallInteger(index, value)) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1895 |
val = __intVal(value); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1896 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1897 |
indx = __intVal(index) - 1; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1898 |
if (((unsigned)(indx)) < sizeof(LONGFLOAT)) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1899 |
cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue)); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1900 |
cp[indx] = val; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1901 |
RETURN ( value ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1902 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1903 |
} |
7415 | 1904 |
} |
1905 |
%}. |
|
1906 |
value isInteger ifFalse:[ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1907 |
" |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1908 |
the object to store should be an integer number |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1909 |
" |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1910 |
^ self elementNotInteger |
7415 | 1911 |
]. |
1912 |
(value between:0 and:255) ifFalse:[ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1913 |
" |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1914 |
the object to store must be a bytes value |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1915 |
" |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1916 |
^ self elementBoundsError:value |
7415 | 1917 |
]. |
1918 |
^ self indexNotIntegerOrOutOfBounds:index |
|
1919 |
! |
|
1920 |
||
1921 |
basicSize |
|
1922 |
"return the size in bytes of the float. |
|
1923 |
||
10333 | 1924 |
Notice: |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1925 |
the need to redefine this method here is due to the |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1926 |
inability of many machines to store floats in non-double aligned memory. |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1927 |
Therefore, on some machines, the first <nPad> bytes of a float are left unused, |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1928 |
and the actual float is stored at index <nPad>+1 ... |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1929 |
To hide this at one place, this method knows about that, and returns |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
1930 |
values as if this filler wasnt present." |
7415 | 1931 |
|
1932 |
%{ /* NOCONTEXT */ |
|
1933 |
||
8913 | 1934 |
RETURN (__mkSmallInteger(sizeof(LONGFLOAT))); |
7415 | 1935 |
%}. |
1936 |
! ! |
|
1937 |
||
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1938 |
!LongFloat methodsFor:'special access'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1939 |
|
7382 | 1940 |
exponent |
21851 | 1941 |
"extract a normalized float's exponent. |
7382 | 1942 |
The returned value depends on the float-representation of |
1943 |
the underlying machine and is therefore highly unportable. |
|
1944 |
This is not for general use. |
|
1945 |
This assumes that the mantissa is normalized to |
|
21851 | 1946 |
0.5 .. 1.0 and the float's value is mantissa * 2^exp" |
7382 | 1947 |
|
1948 |
%{ /* NOCONTEXT */ |
|
1949 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1950 |
#if defined(LONG_frexp) |
8913 | 1951 |
int exp; |
7382 | 1952 |
|
1953 |
LONG_frexp( __longFloatVal(self), &exp); |
|
14743 | 1954 |
RETURN (__mkSmallInteger(exp)); |
7382 | 1955 |
#endif |
1956 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
1957 |
^ super exponent |
7382 | 1958 |
|
1959 |
" |
|
14745 | 1960 |
4.0q exponent |
1961 |
2.0q exponent |
|
1962 |
1.0q exponent |
|
1963 |
0.5q exponent |
|
1964 |
0.25q exponent |
|
1965 |
0.00000011111q exponent |
|
21851 | 1966 |
1.0q1000 exponent |
7382 | 1967 |
" |
21851 | 1968 |
|
1969 |
"Modified (comment): / 20-06-2017 / 11:20:40 / cg" |
|
14743 | 1970 |
! |
1971 |
||
1972 |
mantissa |
|
1973 |
"extract a normalized floats mantissa. |
|
1974 |
The returned value depends on the float-representation of |
|
1975 |
the underlying machine and is therefore highly unportable. |
|
1976 |
This is not for general use. |
|
1977 |
This assumes that the mantissa is normalized to |
|
1978 |
0.5 .. 1.0 and the floats value is mantissa * 2^exp" |
|
1979 |
||
1980 |
%{ /* NOCONTEXT */ |
|
1981 |
#if defined(LONG_frexp) |
|
1982 |
LONGFLOAT frac; |
|
1983 |
int exp; |
|
1984 |
OBJ v; |
|
1985 |
||
1986 |
frac = LONG_frexp( __longFloatVal(self), &exp); |
|
1987 |
__qMKLFLOAT(v, frac); |
|
1988 |
RETURN (v); |
|
1989 |
#endif |
|
1990 |
%}. |
|
21851 | 1991 |
^ super mantissa |
14743 | 1992 |
|
1993 |
" |
|
14745 | 1994 |
1.0q exponent |
1995 |
1.0q asLongFloat mantissa |
|
1996 |
||
1997 |
0.5q exponent |
|
1998 |
0.5q mantissa |
|
1999 |
||
2000 |
0.25q exponent |
|
2001 |
0.25q mantissa |
|
2002 |
||
2003 |
0.00000011111q exponent |
|
2004 |
0.00000011111q mantissa |
|
14743 | 2005 |
" |
21851 | 2006 |
|
2007 |
"Modified: / 20-06-2017 / 11:33:24 / cg" |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2008 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2009 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2010 |
!LongFloat methodsFor:'testing'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2011 |
|
7382 | 2012 |
isFinite |
10333 | 2013 |
"return true, if the receiver is a finite float |
7382 | 2014 |
i.e. not NaN and not infinite." |
2015 |
||
2016 |
%{ /* NOCONTEXT */ |
|
2017 |
||
7396 | 2018 |
#ifdef LONG_finite |
2019 |
LONGFLOAT lV = __longFloatVal(self); |
|
2020 |
||
2021 |
if (LONG_finite(lV)) { |
|
10333 | 2022 |
RETURN (true); |
7396 | 2023 |
} else { |
10333 | 2024 |
RETURN (false); |
7396 | 2025 |
} |
2026 |
#else |
|
7382 | 2027 |
double dV = (double) __longFloatVal(self); |
2028 |
||
8980
abee9fcb0385
cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
2029 |
if (isfinite(dV)) { |
10333 | 2030 |
RETURN (true); |
7396 | 2031 |
} else { |
10333 | 2032 |
RETURN (false); |
7396 | 2033 |
} |
7382 | 2034 |
#endif |
7396 | 2035 |
%} |
7382 | 2036 |
|
2037 |
" |
|
10333 | 2038 |
1.0 asLongFloat isFinite |
2039 |
(0.0 asLongFloat uncheckedDivide: 0.0) isFinite |
|
2040 |
(1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
|
2041 |
(-1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
|
7382 | 2042 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2043 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2044 |
|
7382 | 2045 |
isNaN |
2046 |
"return true, if the receiver is an invalid float (NaN - not a number). |
|
2047 |
These are not created by ST/X float operations (they raise an exception); |
|
2048 |
however, inline C-code could produce them ..." |
|
2049 |
||
2050 |
%{ /* NOCONTEXT */ |
|
2051 |
||
7396 | 2052 |
#ifdef LONG_isnan |
2053 |
LONGFLOAT lV = __longFloatVal(self); |
|
10333 | 2054 |
if (LONG_isnan(lV)) { |
2055 |
RETURN (true); |
|
7396 | 2056 |
} else { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2057 |
RETURN (false); |
7396 | 2058 |
} |
2059 |
#else |
|
7382 | 2060 |
double dV = (double)(__longFloatVal(self)); |
2061 |
||
7396 | 2062 |
if (isnan(dV)) { |
10333 | 2063 |
RETURN (true); |
7396 | 2064 |
} else { |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2065 |
RETURN (false); |
7396 | 2066 |
} |
7382 | 2067 |
#endif |
7396 | 2068 |
%} |
7382 | 2069 |
|
2070 |
" |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2071 |
1.0 asLongFloat isNaN |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2072 |
(0.0 asLongFloat uncheckedDivide: 0.0) isNaN |
7382 | 2073 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2074 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2075 |
|
17381 | 2076 |
isNegativeZero |
2077 |
"many systems have two float.Pnt zeros" |
|
2078 |
||
17395 | 2079 |
%{ /* NOCONTEXT */ |
17393 | 2080 |
#if defined(__BORLANDC__) |
2081 |
union { LONGFLOAT ld; int i[3]; } __u; |
|
2082 |
__u.ld = __longFloatVal(self); |
|
2083 |
RETURN ( (__u.ld == 0.0 && (__u.i[2] & 0x8000)) ? true : false ); |
|
17390 | 2084 |
#else |
17381 | 2085 |
RETURN ( (__longFloatVal(self) == 0.0 && signbit(__longFloatVal(self)) != 0) ? true : false ); |
17390 | 2086 |
#endif |
17381 | 2087 |
%}. |
2088 |
||
2089 |
" |
|
2090 |
0.0 asLongFloat isNegativeZero |
|
2091 |
-0.0 asLongFloat isNegativeZero |
|
2092 |
" |
|
2093 |
! |
|
2094 |
||
7382 | 2095 |
negative |
17381 | 2096 |
"return true if the receiver is less than zero. |
2097 |
-0.0 is positive for now." |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2098 |
|
7382 | 2099 |
%{ /* NOCONTEXT */ |
2100 |
||
17381 | 2101 |
RETURN ( __longFloatVal(self) < 0.0 ? true : false ); |
2102 |
// RETURN ( signbit(__longFloatVal(self)) != 0 ? true : false ); |
|
5411 | 2103 |
%}. |
17381 | 2104 |
|
2105 |
" |
|
18363 | 2106 |
0.0 asLongFloat negative |
2107 |
-0.0 asLongFloat negative |
|
2108 |
1.0 asLongFloat negative |
|
2109 |
-1.0 asLongFloat negative |
|
2110 |
(1.0 uncheckedDivide: 0.0) asLongFloat negative |
|
2111 |
(-1.0 uncheckedDivide: 0.0) asLongFloat negative |
|
17381 | 2112 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2113 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2114 |
|
7382 | 2115 |
numberOfBits |
2116 |
"return the size (in bits) of the real; |
|
2117 |
typically, 80 or 96 is returned here, |
|
2118 |
but who knows ..." |
|
2119 |
||
2120 |
%{ /* NOCONTEXT */ |
|
2121 |
||
8913 | 2122 |
RETURN (__mkSmallInteger (sizeof(LONGFLOAT) * 8)); |
7382 | 2123 |
%} |
2124 |
||
2125 |
" |
|
10333 | 2126 |
LongFloat basicNew numberOfBits |
2127 |
1.2 asLongFloat numberOfBits |
|
2128 |
1.2 asShortFloat numberOfBits |
|
2129 |
1.2 numberOfBits |
|
7382 | 2130 |
" |
5357 | 2131 |
! |
2132 |
||
7382 | 2133 |
positive |
18853 | 2134 |
"return true if the receiver is greater or equal to zero (not negative) |
17381 | 2135 |
0.0 and -0.0 are positive for now." |
7382 | 2136 |
|
2137 |
%{ /* NOCONTEXT */ |
|
2138 |
||
17381 | 2139 |
RETURN ( __longFloatVal(self) >= 0.0 ? true : false ); |
2140 |
// RETURN ( (signbit(__longFloatVal(self)) == 0 ? true : false ) ); |
|
2141 |
%}. |
|
2142 |
||
2143 |
" |
|
19266 | 2144 |
0.0 asLongFloat positive |
2145 |
-0.0 asLongFloat positive |
|
2146 |
1.0 asLongFloat positive |
|
2147 |
-1.0 asLongFloat positive |
|
2148 |
(1.0 uncheckedDivide: 0.0) asLongFloat positive |
|
2149 |
(-1.0 uncheckedDivide: 0.0) asLongFloat positive |
|
17381 | 2150 |
" |
7382 | 2151 |
! |
2152 |
||
2153 |
strictlyPositive |
|
2154 |
"return true if the receiver is greater than zero" |
|
2155 |
||
2156 |
%{ /* NOCONTEXT */ |
|
2157 |
||
2158 |
RETURN ( (__longFloatVal(self) > 0.0) ? true : false ); |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2159 |
%} |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2160 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2161 |
|
7385 | 2162 |
!LongFloat methodsFor:'trigonometric'! |
2163 |
||
2164 |
arcCos |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2165 |
"return the arccosine of the receiver (as radians). |
7385 | 2166 |
Raises an exception, if the receiver is not in -1..1" |
2167 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2168 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2169 |
|
10333 | 2170 |
%{ |
7385 | 2171 |
#if defined(LONG_acos) |
2172 |
||
2173 |
LONGFLOAT val, rslt; |
|
2174 |
OBJ newFloat; |
|
2175 |
||
2176 |
val = __longFloatVal(self); |
|
2177 |
||
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
2178 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7385 | 2179 |
if ((val >= -1.0) && (val <= 1.0)) |
2180 |
# endif |
|
2181 |
{ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2182 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2183 |
rslt = LONG_acos(val); |
7385 | 2184 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2185 |
if (! LONG_isnan(rslt)) |
7385 | 2186 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2187 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2188 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2189 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2190 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2191 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2192 |
} |
7385 | 2193 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2194 |
#else |
7395 | 2195 |
useFallBack = true; |
7385 | 2196 |
#endif |
2197 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2198 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2199 |
^ super arcCos |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2200 |
]. |
7385 | 2201 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2202 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2203 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2204 |
selector:#arcCos |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2205 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2206 |
errorString:'bad receiver in arcCos' |
7385 | 2207 |
|
2208 |
" |
|
2209 |
-10 asLongFloat arcCos |
|
10333 | 2210 |
1 asLongFloat arcCos |
2211 |
0.5 asLongFloat arcCos |
|
7385 | 2212 |
" |
2213 |
! |
|
2214 |
||
2215 |
arcCosh |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2216 |
"return the hyperbolic arccosine of the receiver." |
10333 | 2217 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2218 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2219 |
|
10333 | 2220 |
%{ |
7385 | 2221 |
#if defined(LONG_acosh) |
10333 | 2222 |
|
7385 | 2223 |
LONGFLOAT val, rslt; |
2224 |
OBJ newFloat; |
|
10333 | 2225 |
|
7385 | 2226 |
val = __longFloatVal(self); |
10333 | 2227 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
2228 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2229 |
if (val >= 1.0) |
7385 | 2230 |
# endif |
2231 |
{ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2232 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2233 |
rslt = LONG_acosh(val); |
7385 | 2234 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2235 |
if (! LONG_isnan(rslt)) |
7385 | 2236 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2237 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2238 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2239 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2240 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2241 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2242 |
} |
7385 | 2243 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2244 |
#else |
7395 | 2245 |
useFallBack = true; |
7385 | 2246 |
#endif |
2247 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2248 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2249 |
^ super arcCosh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2250 |
]. |
7385 | 2251 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2252 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2253 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2254 |
selector:#arcCosh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2255 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2256 |
errorString:'bad receiver in arcCosh' |
10333 | 2257 |
|
7385 | 2258 |
" |
2259 |
-10 asLongFloat arcCosh |
|
2260 |
1 asLongFloat arcCosh |
|
2261 |
0.5 asLongFloat arcCosh |
|
2262 |
" |
|
2263 |
! |
|
2264 |
||
2265 |
arcSin |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2266 |
"return the arcsine of the receiver (as radians). |
7385 | 2267 |
Raises an exception, if the receiver is not in -1..1" |
2268 |
||
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2269 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2270 |
|
10333 | 2271 |
%{ |
7385 | 2272 |
#if defined(LONG_asin) |
2273 |
||
2274 |
LONGFLOAT val, rslt; |
|
2275 |
OBJ newFloat; |
|
2276 |
||
2277 |
val = __longFloatVal(self); |
|
2278 |
||
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
2279 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7385 | 2280 |
if ((val >= -1.0) && (val <= 1.0)) |
2281 |
# endif |
|
2282 |
{ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2283 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2284 |
rslt = LONG_asin(val); |
7385 | 2285 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2286 |
if (! LONG_isnan(rslt)) |
7385 | 2287 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2288 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2289 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2290 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2291 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2292 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2293 |
} |
7385 | 2294 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2295 |
#else |
7395 | 2296 |
useFallBack = true; |
7385 | 2297 |
#endif |
2298 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2299 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2300 |
^ super arcSin |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2301 |
]. |
7385 | 2302 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2303 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2304 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2305 |
selector:#arcSin |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2306 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2307 |
errorString:'bad receiver in arcSin' |
7385 | 2308 |
|
2309 |
" |
|
2310 |
-10 asLongFloat arcSin |
|
10333 | 2311 |
1 asLongFloat arcSin |
2312 |
0.5 asLongFloat arcSin |
|
7385 | 2313 |
" |
2314 |
! |
|
2315 |
||
2316 |
arcSinh |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2317 |
"return the hyperbolic arcsine of the receiver." |
10333 | 2318 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2319 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2320 |
|
10333 | 2321 |
%{ |
7385 | 2322 |
#if defined(LONG_asinh) |
10333 | 2323 |
|
7385 | 2324 |
LONGFLOAT val, rslt; |
2325 |
OBJ newFloat; |
|
10333 | 2326 |
|
7385 | 2327 |
val = __longFloatVal(self); |
10333 | 2328 |
|
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
2329 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2330 |
if (val >= 1.0) |
7385 | 2331 |
# endif |
2332 |
{ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2333 |
__threadErrno = 0; |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2334 |
rslt = LONG_asinh(val); |
7385 | 2335 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2336 |
if (! LONG_isnan(rslt)) |
7385 | 2337 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2338 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2339 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2340 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2341 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2342 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2343 |
} |
7385 | 2344 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2345 |
#else |
7395 | 2346 |
useFallBack = true; |
7385 | 2347 |
#endif |
2348 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2349 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2350 |
^ super arcSinh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2351 |
]. |
7385 | 2352 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2353 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2354 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2355 |
selector:#arcSinh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2356 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2357 |
errorString:'bad receiver in arcSinh' |
10333 | 2358 |
|
7385 | 2359 |
" |
2360 |
-10 asLongFloat arcSinh |
|
2361 |
1 asLongFloat arcSinh |
|
2362 |
0.5 asLongFloat arcSinh |
|
2363 |
" |
|
2364 |
! |
|
2365 |
||
2366 |
arcTan |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2367 |
"return the arctangent of the receiver (as radians)" |
7385 | 2368 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2369 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2370 |
|
10333 | 2371 |
%{ |
7385 | 2372 |
#if defined(LONG_atan) |
2373 |
||
2374 |
LONGFLOAT rslt; |
|
2375 |
OBJ newFloat; |
|
2376 |
||
2377 |
__threadErrno = 0; |
|
2378 |
rslt = LONG_atan(__longFloatVal(self)); |
|
2379 |
# ifdef LONG_isnan |
|
2380 |
if (! LONG_isnan(rslt)) |
|
2381 |
# endif |
|
2382 |
{ |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2383 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2384 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2385 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2386 |
} |
7385 | 2387 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2388 |
#else |
7395 | 2389 |
useFallBack = true; |
7385 | 2390 |
#endif |
2391 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2392 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2393 |
^ super arcTan |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2394 |
]. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2395 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2396 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2397 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2398 |
selector:#arcTan |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2399 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2400 |
errorString:'bad receiver in arcTan' |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2401 |
! |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2402 |
|
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2403 |
arcTanh |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2404 |
"return the hyperbolic arctangent of the receiver." |
10333 | 2405 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2406 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2407 |
|
10333 | 2408 |
%{ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2409 |
#if defined(LONG_atanh) |
10333 | 2410 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2411 |
LONGFLOAT val, rslt; |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2412 |
OBJ newFloat; |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2413 |
|
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2414 |
val = __longFloatVal(self); |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2415 |
__threadErrno = 0; |
19860
324edacff5cc
unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents:
19570
diff
changeset
|
2416 |
# ifdef __win32__ /* to suppress the warnBox opened by win32 */ |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2417 |
if ((val >= -1.0) && (val <= 1.0)) |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2418 |
# endif |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2419 |
{ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2420 |
rslt = LONG_atanh(val); |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2421 |
# ifdef LONG_isnan |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2422 |
if (! LONG_isnan(rslt)) |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2423 |
# endif |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2424 |
{ |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2425 |
if (__threadErrno == 0) { |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2426 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2427 |
RETURN ( newFloat ); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2428 |
} |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2429 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2430 |
} |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2431 |
#else |
7395 | 2432 |
useFallBack = true; |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2433 |
#endif |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2434 |
%}. |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2435 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2436 |
^ super arcTanh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2437 |
]. |
7385 | 2438 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2439 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2440 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2441 |
selector:#arcTanh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2442 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2443 |
errorString:'bad receiver in arcTanh' |
7385 | 2444 |
! |
2445 |
||
2446 |
cos |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2447 |
"return the cosine of the receiver (interpreted as radians)" |
7385 | 2448 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2449 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2450 |
|
10333 | 2451 |
%{ |
7385 | 2452 |
#if defined(LONG_cos) |
2453 |
||
2454 |
LONGFLOAT rslt; |
|
2455 |
OBJ newFloat; |
|
2456 |
||
2457 |
__threadErrno = 0; |
|
2458 |
rslt = LONG_cos(__longFloatVal(self)); |
|
2459 |
# ifdef LONG_isnan |
|
2460 |
if (! LONG_isnan(rslt)) |
|
2461 |
# endif |
|
2462 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2463 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2464 |
RETURN ( newFloat ); |
7385 | 2465 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2466 |
#else |
7395 | 2467 |
useFallBack = true; |
7385 | 2468 |
#endif |
2469 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2470 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2471 |
^ super cos |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2472 |
]. |
7385 | 2473 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2474 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2475 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2476 |
selector:#cos |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2477 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2478 |
errorString:'bad receiver in cos' |
7385 | 2479 |
! |
2480 |
||
2481 |
cosh |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2482 |
"return the hyperbolic cosine of the receiver" |
10333 | 2483 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2484 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2485 |
|
10333 | 2486 |
%{ |
7385 | 2487 |
#if defined(LONG_cosh) |
10333 | 2488 |
|
7385 | 2489 |
LONGFLOAT rslt; |
2490 |
OBJ newFloat; |
|
10333 | 2491 |
|
7385 | 2492 |
__threadErrno = 0; |
2493 |
rslt = LONG_cosh(__longFloatVal(self)); |
|
2494 |
# ifdef LONG_isnan |
|
2495 |
if (! LONG_isnan(rslt)) |
|
2496 |
# endif |
|
2497 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2498 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2499 |
RETURN ( newFloat ); |
7385 | 2500 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2501 |
#else |
7395 | 2502 |
useFallBack = true; |
7385 | 2503 |
#endif |
2504 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2505 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2506 |
^ super cosh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2507 |
]. |
7385 | 2508 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2509 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2510 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2511 |
selector:#cosh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2512 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2513 |
errorString:'bad receiver in cosh' |
7385 | 2514 |
! |
2515 |
||
2516 |
sin |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2517 |
"return the sine of the receiver (interpreted as radians)" |
7385 | 2518 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2519 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2520 |
|
10333 | 2521 |
%{ |
7385 | 2522 |
#if defined(LONG_sin) |
2523 |
||
2524 |
LONGFLOAT rslt; |
|
2525 |
OBJ newFloat; |
|
2526 |
||
2527 |
__threadErrno = 0; |
|
2528 |
rslt = LONG_sin(__longFloatVal(self)); |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2529 |
# ifdef LONG_isnan |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2530 |
if (! LONG_isnan(rslt)) |
7385 | 2531 |
# endif |
2532 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2533 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2534 |
RETURN ( newFloat ); |
7385 | 2535 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2536 |
#else |
7395 | 2537 |
useFallBack = true; |
7385 | 2538 |
#endif |
2539 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2540 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2541 |
^ super sin |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2542 |
]. |
7385 | 2543 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2544 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2545 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2546 |
selector:#sin |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2547 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2548 |
errorString:'bad receiver in sin' |
7385 | 2549 |
! |
2550 |
||
2551 |
sinh |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2552 |
"return the hyperbolic sine of the receiver" |
10333 | 2553 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2554 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2555 |
|
10333 | 2556 |
%{ |
7385 | 2557 |
#if defined(LONG_sinh) |
10333 | 2558 |
|
7385 | 2559 |
LONGFLOAT rslt; |
2560 |
OBJ newFloat; |
|
10333 | 2561 |
|
7385 | 2562 |
__threadErrno = 0; |
2563 |
rslt = LONG_sinh(__longFloatVal(self)); |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2564 |
# ifdef LONG_isnan |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2565 |
if (! LONG_isnan(rslt)) |
7385 | 2566 |
# endif |
2567 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2568 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2569 |
RETURN ( newFloat ); |
7385 | 2570 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2571 |
#else |
7395 | 2572 |
useFallBack = true; |
7385 | 2573 |
#endif |
2574 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2575 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2576 |
^ super sinh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2577 |
]. |
7385 | 2578 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2579 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2580 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2581 |
selector:#sinh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2582 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2583 |
errorString:'bad receiver in sinh' |
7385 | 2584 |
! |
2585 |
||
2586 |
tan |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2587 |
"return the tangens of the receiver (interpreted as radians)" |
7385 | 2588 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2589 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2590 |
|
10333 | 2591 |
%{ |
7385 | 2592 |
#if defined(LONG_tan) |
2593 |
||
2594 |
LONGFLOAT rslt; |
|
2595 |
OBJ newFloat; |
|
2596 |
||
2597 |
__threadErrno = 0; |
|
2598 |
rslt = LONG_tan(__longFloatVal(self)); |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2599 |
# ifdef LONG_isnan |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2600 |
if (! LONG_isnan(rslt)) |
7385 | 2601 |
# endif |
2602 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2603 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2604 |
RETURN ( newFloat ); |
7385 | 2605 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2606 |
#else |
7395 | 2607 |
useFallBack = true; |
7385 | 2608 |
#endif |
2609 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2610 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2611 |
^ super tan |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2612 |
]. |
7385 | 2613 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2614 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2615 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2616 |
selector:#tan |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2617 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2618 |
errorString:'bad receiver in tan' |
7385 | 2619 |
! |
2620 |
||
2621 |
tanh |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2622 |
"return the hyperbolic tangens of the receiver" |
10333 | 2623 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2624 |
|useFallBack| |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2625 |
|
10333 | 2626 |
%{ |
7385 | 2627 |
#if defined(LONG_tanh) |
2628 |
LONGFLOAT rslt; |
|
2629 |
OBJ newFloat; |
|
10333 | 2630 |
|
7385 | 2631 |
__threadErrno = 0; |
2632 |
rslt = LONG_tanh(__longFloatVal(self)); |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2633 |
# ifdef LONG_isnan |
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2634 |
if (! LONG_isnan(rslt)) |
7385 | 2635 |
# endif |
2636 |
if (__threadErrno == 0) { |
|
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2637 |
__qMKLFLOAT(newFloat, rslt); |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2638 |
RETURN ( newFloat ); |
7385 | 2639 |
} |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2640 |
#else |
7395 | 2641 |
useFallBack = true; |
7385 | 2642 |
#endif |
2643 |
%}. |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2644 |
useFallBack notNil ifTrue:[ |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2645 |
^ super tanh |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2646 |
]. |
7385 | 2647 |
^ self class |
7731
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2648 |
raise:#domainErrorSignal |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2649 |
receiver:self |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2650 |
selector:#tanh |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2651 |
arguments:#() |
abbf80b3913b
Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents:
7728
diff
changeset
|
2652 |
errorString:'bad receiver in tanh' |
7385 | 2653 |
! ! |
2654 |
||
5552 | 2655 |
!LongFloat methodsFor:'truncation & rounding'! |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2656 |
|
7382 | 2657 |
ceiling |
2658 |
"return the smallest integer which is greater or equal to the receiver." |
|
2659 |
||
2660 |
|val| |
|
2661 |
||
2662 |
%{ |
|
2663 |
#if defined(LONG_ceil) |
|
2664 |
LONGFLOAT lVal; |
|
2665 |
||
2666 |
lVal = LONG_ceil(__longFloatVal(self)); |
|
2667 |
if ((lVal >= (LONGFLOAT)_MIN_INT) && (lVal <= (LONGFLOAT)_MAX_INT)) { |
|
14931 | 2668 |
RETURN ( __mkSmallInteger( (INT) lVal ) ); |
7382 | 2669 |
} |
2670 |
__qMKLFLOAT(val, lVal); |
|
2671 |
#endif |
|
2672 |
%}. |
|
2673 |
val notNil ifTrue:[ |
|
14931 | 2674 |
^ val asInteger |
7382 | 2675 |
]. |
2676 |
^ super ceiling. |
|
2677 |
||
2678 |
" |
|
14745 | 2679 |
0.5q ceiling |
2680 |
-0.5q ceiling |
|
7382 | 2681 |
" |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2682 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2683 |
|
7382 | 2684 |
ceilingAsFloat |
2685 |
"return the smallest integer-valued float greater or equal to the receiver. |
|
10333 | 2686 |
This is much like #ceiling, but avoids a (possibly expensive) conversion |
7382 | 2687 |
of the result to an integer. |
2688 |
It may be useful, if the result is to be further used in another float-operation." |
|
2689 |
||
2690 |
%{ /* NOCONTEXT */ |
|
2691 |
#if defined(LONG_ceil) |
|
2692 |
LONGFLOAT lVal; |
|
2693 |
OBJ v; |
|
2694 |
||
2695 |
lVal = LONG_ceil(__longFloatVal(self)); |
|
2696 |
__qMKLFLOAT(v, lVal); |
|
2697 |
RETURN (v); |
|
2698 |
#endif |
|
2699 |
%}. |
|
2700 |
^ super ceilingAsFloat |
|
2701 |
||
2702 |
" |
|
14745 | 2703 |
0.5q ceilingAsFloat |
2704 |
-0.5q ceilingAsFloat |
|
2705 |
-1.5q ceilingAsFloat |
|
7382 | 2706 |
" |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2707 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2708 |
|
7382 | 2709 |
floor |
2710 |
"return the integer nearest the receiver towards negative infinity." |
|
2711 |
||
2712 |
|val| |
|
2713 |
||
2714 |
%{ |
|
2715 |
#if defined(LONG_floor) |
|
2716 |
LONGFLOAT lVal; |
|
2717 |
||
2718 |
lVal = LONG_floor(__longFloatVal(self)); |
|
2719 |
if ((lVal >= (LONGFLOAT)_MIN_INT) && (lVal <= (LONGFLOAT)_MAX_INT)) { |
|
14931 | 2720 |
RETURN ( __mkSmallInteger( (INT) lVal ) ); |
7382 | 2721 |
} |
2722 |
__qMKLFLOAT(val, lVal); |
|
2723 |
#endif |
|
2724 |
%}. |
|
2725 |
val notNil ifTrue:[ |
|
14931 | 2726 |
^ val asInteger |
7382 | 2727 |
]. |
2728 |
^ super floor. |
|
2729 |
||
2730 |
" |
|
14745 | 2731 |
0.5q floor |
2732 |
-0.5q floor |
|
7382 | 2733 |
" |
2734 |
! |
|
2735 |
||
2736 |
floorAsFloat |
|
2737 |
"return the float which represents the next lower |
|
2738 |
integer nearest the receiver towards negative infinity. |
|
2739 |
Much like floor, but returns a float result - useful if the result |
|
2740 |
will be used in another float operation, to avoid costy int-conversion." |
|
2741 |
||
2742 |
%{ /* NOCONTEXT */ |
|
2743 |
#if defined(LONG_floor) |
|
2744 |
LONGFLOAT lVal; |
|
2745 |
OBJ v; |
|
2746 |
||
2747 |
lVal = LONG_floor(__longFloatVal(self)); |
|
2748 |
__qMKLFLOAT(v, lVal); |
|
2749 |
RETURN (v); |
|
2750 |
#endif |
|
2751 |
%}. |
|
2752 |
^ super floorAsFloat |
|
2753 |
||
2754 |
" |
|
14745 | 2755 |
0.5q floorAsFloat |
2756 |
-0.5q floorAsFloat |
|
2757 |
-1.5q floorAsFloat |
|
7382 | 2758 |
" |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2759 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2760 |
|
14743 | 2761 |
fractionPart |
2762 |
"extract the after-decimal fraction part. |
|
2763 |
such that (self truncated + self fractionPart) = self" |
|
2764 |
||
2765 |
%{ /* NOCONTEXT */ |
|
2766 |
#if defined(LONG_modf) |
|
2767 |
LONGFLOAT frac, trunc; |
|
2768 |
OBJ v; |
|
2769 |
||
19322 | 2770 |
// mingw64 runtime modfl has a bug, triggering a SEGV |
2771 |
// see https://sourceforge.net/p/mingw-w64/bugs/478/ |
|
2772 |
# if defined(MINGW_MODFL_BUG) |
|
2773 |
{ |
|
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
2774 |
LONGFLOAT value = __longFloatVal(self); |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
2775 |
LONGFLOAT int_part = LONG_trunc(value); |
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
2776 |
frac = (isinf (value) ? 0.0L : value - int_part); |
19322 | 2777 |
} |
2778 |
# else |
|
14743 | 2779 |
frac = LONG_modf(__longFloatVal(self), &trunc); |
19329
52f5c0de20b4
LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents:
19324
diff
changeset
|
2780 |
# endif |
14743 | 2781 |
__qMKLFLOAT(v, frac); |
2782 |
RETURN (v); |
|
2783 |
#endif |
|
2784 |
%}. |
|
2785 |
^ super fractionPart |
|
2786 |
||
2787 |
" |
|
14745 | 2788 |
1.6q fractionPart + 1.6q truncated |
2789 |
-1.6q fractionPart + -1.6q truncated |
|
2790 |
||
2791 |
1.0q fractionPart |
|
2792 |
2.0q fractionPart |
|
14743 | 2793 |
3.0 asLongFloat fractionPart |
2794 |
4.0 asLongFloat fractionPart |
|
2795 |
0.5 asLongFloat fractionPart |
|
2796 |
0.25 asLongFloat fractionPart |
|
2797 |
3.14159 asLongFloat fractionPart |
|
2798 |
12345673.14159 asLongFloat fractionPart |
|
2799 |
123456731231231231.14159 asLongFloat fractionPart |
|
2800 |
||
2801 |
3.14159 asLongFloat fractionPart + 3.14159 asLongFloat truncated |
|
2802 |
||
2803 |
12345673.14159 asLongFloat fractionPart + 12345673.14159 asLongFloat truncated |
|
2804 |
||
2805 |
123456731231231231.14159 asLongFloat fractionPart + 123456731231231231.14159 asLongFloat truncated |
|
2806 |
" |
|
2807 |
! |
|
2808 |
||
7382 | 2809 |
rounded |
2810 |
"return the receiver rounded to the nearest integer" |
|
2811 |
||
2812 |
%{ /* NOCONTEXT */ |
|
2813 |
#if defined(LONG_ceil) && defined(LONG_floor) |
|
2814 |
LONGFLOAT lVal; |
|
2815 |
OBJ v; |
|
2816 |
||
2817 |
lVal = __longFloatVal(self); |
|
2818 |
if (lVal < 0.0) { |
|
14931 | 2819 |
lVal = LONG_ceil(lVal - (LONGFLOAT)0.5); |
7382 | 2820 |
} else { |
14931 | 2821 |
lVal = LONG_floor(lVal + (LONGFLOAT)0.5); |
7382 | 2822 |
} |
2823 |
/* |
|
2824 |
* ST-80 (and X3J20) returns integer. |
|
2825 |
*/ |
|
2826 |
if ((lVal >= (LONGFLOAT)_MIN_INT) && (lVal <= (LONGFLOAT)_MAX_INT)) { |
|
14931 | 2827 |
RETURN ( __mkSmallInteger( (INT) lVal ) ); |
7382 | 2828 |
} |
2829 |
__qMKLFLOAT(v, lVal); |
|
2830 |
RETURN (v); |
|
2831 |
#endif |
|
2832 |
%}. |
|
2833 |
^ super rounded |
|
2834 |
||
2835 |
" |
|
14745 | 2836 |
0.4q rounded |
2837 |
0.5q rounded |
|
2838 |
0.6qqrounded |
|
2839 |
-0.4q rounded |
|
2840 |
-0.5q rounded |
|
2841 |
-0.6q rounded |
|
7382 | 2842 |
" |
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2843 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2844 |
|
7382 | 2845 |
roundedAsFloat |
2846 |
"return the receiver rounded to the nearest integer as a float. |
|
10333 | 2847 |
This is much like #rounded, but avoids a (possibly expensive) conversion |
7382 | 2848 |
of the result to an integer. |
2849 |
It may be useful, if the result is to be further used in another float-operation." |
|
2850 |
||
2851 |
%{ /* NOCONTEXT */ |
|
2852 |
#if defined(LONG_ceil) && defined(LONG_floor) |
|
2853 |
LONGFLOAT lVal; |
|
2854 |
OBJ v; |
|
2855 |
||
2856 |
lVal = __longFloatVal(self); |
|
2857 |
if (lVal < 0.0) { |
|
2858 |
lVal = LONG_ceil(lVal - (LONGFLOAT)0.5); |
|
2859 |
} else { |
|
2860 |
lVal = LONG_floor(lVal + (LONGFLOAT)0.5); |
|
2861 |
} |
|
2862 |
__qMKLFLOAT(v, lVal); |
|
2863 |
RETURN (v); |
|
2864 |
#endif |
|
2865 |
%}. |
|
2866 |
^ super roundedAsFloat |
|
7357
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2867 |
! |
cde54b45c469
full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents:
7141
diff
changeset
|
2868 |
|
7382 | 2869 |
truncated |
2870 |
"return the receiver truncated towards zero as an integer" |
|
2871 |
||
2872 |
|val| |
|
2873 |
||
2874 |
%{ |
|
2875 |
#if defined(LONG_ceil) && defined(LONG_floor) |
|
2876 |
LONGFLOAT lVal; |
|
2877 |
||
2878 |
lVal = __longFloatVal(self); |
|
2879 |
if (lVal < 0.0) { |
|
14931 | 2880 |
lVal = LONG_ceil(lVal); |
7382 | 2881 |
} else { |
14931 | 2882 |
lVal = LONG_floor(lVal); |
7382 | 2883 |
} |
2884 |
||
2885 |
/* |
|
2886 |
* ST-80 (and X3J20) returns integer. |
|
2887 |
*/ |
|
2888 |
if ((lVal >= (LONGFLOAT)_MIN_INT) && (lVal <= (LONGFLOAT)_MAX_INT)) { |
|
14931 | 2889 |
RETURN ( __mkSmallInteger( (INT) lVal ) ); |
7382 | 2890 |
} |
2891 |
__qMKLFLOAT(val, lVal); |
|
2892 |
#endif |
|
2893 |
%}. |
|
2894 |
val notNil ifTrue:[ |
|
14931 | 2895 |
^ val asInteger |
7382 | 2896 |
]. |
2897 |
^ super truncated |
|
2898 |
||
2899 |
" |
|
14745 | 2900 |
0.5q truncated |
2901 |
-0.5q truncated |
|
2902 |
0.5q truncatedAsFloat |
|
2903 |
-0.5q truncatedAsFloat |
|
7382 | 2904 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2905 |
! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2906 |
|
7382 | 2907 |
truncatedAsFloat |
2908 |
"return the receiver truncated towards zero as a float. |
|
10333 | 2909 |
This is much like #truncated, but avoids a (possibly expensive) conversion |
7382 | 2910 |
of the result to an integer. |
10333 | 2911 |
It may be useful, if the result is to be further used in another |
7382 | 2912 |
float-operation." |
2913 |
||
2914 |
%{ /* NOCONTEXT */ |
|
2915 |
#if defined(LONG_ceil) && defined(LONG_floor) |
|
2916 |
LONGFLOAT lVal; |
|
2917 |
OBJ v; |
|
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2918 |
|
7382 | 2919 |
lVal = __longFloatVal(self); |
2920 |
if (lVal < 0.0) { |
|
14931 | 2921 |
lVal = LONG_ceil(lVal); |
7382 | 2922 |
} else { |
14931 | 2923 |
lVal = LONG_floor(lVal); |
7382 | 2924 |
} |
2925 |
__qMKLFLOAT(v, lVal); |
|
2926 |
RETURN (v); |
|
2927 |
#endif |
|
2928 |
%}. |
|
2929 |
^ super truncatedAsFloat |
|
2930 |
||
2931 |
" |
|
14745 | 2932 |
0.5q truncated |
2933 |
-0.5q truncated |
|
2934 |
0.5q truncatedAsFloat |
|
2935 |
-0.5q truncatedAsFloat |
|
7382 | 2936 |
" |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2937 |
! ! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2938 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2939 |
!LongFloat class methodsFor:'documentation'! |
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2940 |
|
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2941 |
version |
18833 | 2942 |
^ '$Header$' |
12476
66b5104cedc9
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11925
diff
changeset
|
2943 |
! |
66b5104cedc9
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11925
diff
changeset
|
2944 |
|
66b5104cedc9
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11925
diff
changeset
|
2945 |
version_CVS |
18833 | 2946 |
^ '$Header$' |
4165
6d83608a7584
initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2947 |
! ! |
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2948 |
|
14600 | 2949 |
|
7389
4fd487ca919a
longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents:
7385
diff
changeset
|
2950 |
LongFloat initialize! |