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