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