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