LongFloat.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Dec 2019 19:09:58 +0100
changeset 25049 1c82be43aa8b
parent 25036 a92213ab83ac
child 25053 e19e11facb6d
permissions -rw-r--r--
NaN
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25022
391997c035aa #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 25013
diff changeset
     1
"{ Encoding: utf8 }"
391997c035aa #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 25013
diff changeset
     2
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
     3
"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
     4
 COPYRIGHT (c) 1999 by eXept Software AG
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	      All Rights Reserved
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 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
     8
 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
     9
 inclusion of the above copyright notice.   This software may not
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 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
    11
 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
    12
 hereby transferred.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
5411
c396c6640868 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
    14
"{ Package: 'stx:libbasic' }"
c396c6640868 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
    15
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
    16
"{ NameSpace: Smalltalk }"
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
    17
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
LimitedPrecisionReal variableByteSubclass:#LongFloat
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
    20
	classVariableNames:'DefaultPrintFormat DefaultPrintfFormat DefaultPrintPrecision
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
    21
		LongFloatZero LongFloatOne Pi E Epsilon NaN PositiveInfinity
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
    22
		NegativeInfinity Halfpi HalfpiNegative Phi'
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	poolDictionaries:''
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	category:'Magnitude-Numbers'
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!LongFloat primitiveDefinitions!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
%{
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
    29
#include <stdio.h>
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
#include <errno.h>
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
#ifndef __OPTIMIZE__
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
# define __OPTIMIZE__
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
#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
    35
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    36
#define __USE_ISOC9X 1
8980
abee9fcb0385 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8913
diff changeset
    37
#define __USE_ISOC99 1
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
#include <math.h>
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
/*
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
    41
 * on some systems, errno is a macro ... check for it here
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
#ifndef errno
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 extern errno;
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
#endif
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
    47
#if !defined (__win32__)
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
    48
# include <locale.h>
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
    49
#endif
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
    50
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
    51
#include <float.h>
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    52
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
    53
#if defined(__irix__) || defined(__solaris__) || defined(__sunos__)
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
# include <nan.h>
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
#endif
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    56
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
    57
#if defined(__osx__)
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
    58
# include <math.h>
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
    59
#endif
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
    60
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
    61
#if defined(__linux__)
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    62
# ifndef NAN
5822
4e56f8aadda5 Get nan.h from bits/nan.h for Linux
Stefan Vogel <sv@exept.de>
parents: 5645
diff changeset
    63
#  include <bits/nan.h>
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    64
# endif
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
#endif
4825
4c77d43433d1 nan trouble with new suse
Claus Gittinger <cg@exept.de>
parents: 4455
diff changeset
    66
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
    67
#ifdef __win32__
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
/*
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
 * no finite(x) ?
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
 * no isnan(x) ?
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
 */
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    72
# ifndef isnanl
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    73
#  define isnanl(x)      \
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    74
	((((unsigned int *)(&x))[0] == 0x00000000) && \
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    75
	 (((unsigned int *)(&x))[1] == 0xC0000000) && \
25049
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    76
	 (((unsigned short *)(&x))[4] & 0x7FFF == 0x7FFF))
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
# endif
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    78
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
# ifndef isnan
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    80
#  define isnan(x)      \
25049
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    81
	((((unsigned int *)(&x))[1] & 0x7FF80000) == 0x7FF80000)
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    82
// old, invalid definition
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    83
// #  define isnan(x)      \
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    84
//         ((((unsigned int *)(&x))[0] == 0x00000000) && \
Claus Gittinger <cg@exept.de>
parents: 25036
diff changeset
    85
//          (((unsigned int *)(&x))[1] == 0xFFF80000))
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    86
# endif
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    87
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    88
# ifndef isPositiveInfinity
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    89
#  define isPositiveInfinity(x) \
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    90
	((((unsigned int *)(&x))[0] == 0x00000000) && \
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    91
	 (((unsigned int *)(&x))[1] == 0x7FF00000))
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    92
# endif
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    93
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    94
# ifndef isNegativeInfinity
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    95
#  define isNegativeInfinity(x) \
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    96
	((((unsigned int *)(&x))[0] == 0x00000000) && \
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
    97
	 (((unsigned int *)(&x))[1] == 0xFFF00000))
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
# endif
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
    99
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   100
# ifndef isinf
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   101
#  define isinf(x) \
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
   102
	((((unsigned int *)(&x))[0] == 0x00000000) && \
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
   103
	 ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   104
# endif
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   105
8981
7c7b2a14c8b3 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8980
diff changeset
   106
# ifndef isfinite
7c7b2a14c8b3 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8980
diff changeset
   107
#  define isfinite(x) (!isinf(x) && !isnan(x))
7417
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   108
# endif
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   109
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   110
# define NO_ASINH
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   111
# define NO_ACOSH
dd08bf7b0aba isnanl for WIN32
Claus Gittinger <cg@exept.de>
parents: 7415
diff changeset
   112
# define NO_ATANH
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
   113
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
   114
# ifdef __MINGW__
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   115
#  ifndef _STRING_H_INCLUDED_
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   116
#   include <string.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   117
#   define _STRING_H_INCLUDED_
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   118
#  endif
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   119
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   120
   // sigh: the default ming setup uses the microsoft printf,
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   121
   // which does not support long doubles
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 22300
diff changeset
   122
#  define snprintf  __mingw_snprintf
19356
5ca3989a13f0 bcc fixes
Claus Gittinger <cg@exept.de>
parents: 19329
diff changeset
   123
# endif /* __MINGW__ */
19329
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
   124
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   125
#endif /* __win32__ */
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   126
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   127
#ifdef __solaris__
8984
ddf3bff73452 isfinite() et.al. for Solaris
Stefan Vogel <sv@exept.de>
parents: 8982
diff changeset
   128
# ifndef isfinite
ddf3bff73452 isfinite() et.al. for Solaris
Stefan Vogel <sv@exept.de>
parents: 8982
diff changeset
   129
#  define isfinite(f) finite((double)(f))
ddf3bff73452 isfinite() et.al. for Solaris
Stefan Vogel <sv@exept.de>
parents: 8982
diff changeset
   130
# endif
ddf3bff73452 isfinite() et.al. for Solaris
Stefan Vogel <sv@exept.de>
parents: 8982
diff changeset
   131
#endif
ddf3bff73452 isfinite() et.al. for Solaris
Stefan Vogel <sv@exept.de>
parents: 8982
diff changeset
   132
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   133
#ifdef __realIX__
8980
abee9fcb0385 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8913
diff changeset
   134
# ifndef isfinite
abee9fcb0385 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8913
diff changeset
   135
#  define isfinite(x)     1
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
# 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
   137
#endif /* realIX */
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   139
#if defined(__GNUC__) || defined(__MINGW__) || defined(__win32__)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   140
# ifndef LONGFLOAT_t
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   141
#  define LONGFLOAT_t      long double
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   142
# endif
8706
d48896f0a910 mac stuff
Claus Gittinger <cg@exept.de>
parents: 8635
diff changeset
   143
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   144
# if defined(__linux__) || defined(__osx__) || defined(__win32__)
7397
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   145
#  define LONG_ceil     ceill
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   146
#  define LONG_floor    floorl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   147
#  define LONG_sqrt     sqrtl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   148
#  define LONG_sin      sinl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   149
#  define LONG_cos      cosl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   150
#  define LONG_tan      tanl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   151
#  define LONG_sinh     sinhl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   152
#  define LONG_cosh     coshl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   153
#  define LONG_tanh     tanhl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   154
#  define LONG_asin     asinl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   155
#  define LONG_acos     acosl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   156
#  define LONG_atan     atanl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   157
#  define LONG_exp      expl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   158
#  define LONG_frexp    frexpl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   159
#  define LONG_log      logl
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   160
#  define LONG_log10    log10l
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
   161
#  define LONG_modf     modfl
19323
299aad6846f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19322
diff changeset
   162
#  define LONG_trunc    truncl
7397
4d2718888bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7396
diff changeset
   163
#  define LONG_pow      powl
17459
701fbb1088ca clang compilability
Claus Gittinger <cg@exept.de>
parents: 17395
diff changeset
   164
#  ifdef __llvm__
701fbb1088ca clang compilability
Claus Gittinger <cg@exept.de>
parents: 17395
diff changeset
   165
#   define LONG_isnan    isnan
701fbb1088ca clang compilability
Claus Gittinger <cg@exept.de>
parents: 17395
diff changeset
   166
#  else
701fbb1088ca clang compilability
Claus Gittinger <cg@exept.de>
parents: 17395
diff changeset
   167
#   define LONG_isnan    isnanl
701fbb1088ca clang compilability
Claus Gittinger <cg@exept.de>
parents: 17395
diff changeset
   168
#  endif
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   169
#  if defined(__osx__)
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   170
#   define LONG_isfinite isfinite
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   171
#  else
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   172
#   define LONG_isfinite isfinitel
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   173
#  endif
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   174
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   175
#  if !defined(__win32__)
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   176
#   define LONG_asinh    asinhl
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   177
#   define LONG_acosh    acoshl
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   178
#   define LONG_atanh    atanhl
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   179
#  endif /* linux */
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   180
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   181
# endif  /* defined(__linux__) || defined(__win32__) */
8706
d48896f0a910 mac stuff
Claus Gittinger <cg@exept.de>
parents: 8635
diff changeset
   182
8981
7c7b2a14c8b3 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8980
diff changeset
   183
# if !defined(LONG_isnan)
7c7b2a14c8b3 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8980
diff changeset
   184
/* This should be true for ISO C99 systems - even for newer linux systems */
8706
d48896f0a910 mac stuff
Claus Gittinger <cg@exept.de>
parents: 8635
diff changeset
   185
#  define LONG_isnan    isnan
d48896f0a910 mac stuff
Claus Gittinger <cg@exept.de>
parents: 8635
diff changeset
   186
#  define LONG_isfinite isfinite
8982
015dc40e3582 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8981
diff changeset
   187
# endif /* !defined(LONG_isnan) */
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   188
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   189
#endif /* defined(__GNUC__) || defined(__win32__) */
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
%}
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
!LongFloat class methodsFor:'documentation'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   196
copyright
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   197
"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   198
 COPYRIGHT (c) 1999 by eXept Software AG
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
	      All Rights Reserved
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
 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
   202
 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
   203
 inclusion of the above copyright notice.   This software may not
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
 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
   205
 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
   206
 hereby transferred.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
"
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
documentation
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
"
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   212
    LongFloats represent rational numbers with limited precision.
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
   213
    They use the C-compiler's 'long double' format,
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
   214
    which is either mapped to the IEEE extended precision (80bit)
24460
7afdbd0458d1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24438
diff changeset
   215
    or IEEE quadruple precision format (128bit).
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   216
7380
c704ff45bb80 documentation
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
   217
    In contrast to Floats (which use the C-compilers 64bit 'double' format),
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   218
    LongFloats give you one of 80 bit extended floats, 96 bit extended floats or 128 bit quadruple floats,
24263
9b19f063bb70 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24255
diff changeset
   219
    depending on the underlying CPU.
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   220
    Thus, code using longFloats is not guaranteed to be portable from one architecture to another,
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   221
    but faster than software emulations.
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   222
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   223
    NOTE:
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   224
	on systems which do not support 'long doubles', LongFloats are (silently)
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   225
	represented as 'doubles'.
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   226
7380
c704ff45bb80 documentation
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
   227
    Representation:
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   228
	gcc-x86:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   229
	    80bit extended IEEE floats stored in in 96bits (12bytes);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   230
	    1 bit integer part,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   231
	    64 bit mantissa,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   232
	    16 bit exponent,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   233
	    19 decimal digits (approx.)
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   234
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   235
	borland-x86 (WIN32):
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   236
	    80bit extended IEEE floats stored in in 80bits (10bytes);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   237
	    1 bit integer part,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   238
	    64 bit mantissa,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   239
	    16 bit exponent,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   240
	    19 decimal digits (approx.)
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   241
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   242
	gcc-x86_64: (WIN64)
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   243
	    like gcc-x86
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   244
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   245
	gcc-sparc:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   246
	    128bit quadruple IEEE floats (16bytes);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   247
	    112 bit mantissa,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   248
	    16 bit exponent,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   249
	    34 decimal digits (approx.)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   250
7380
c704ff45bb80 documentation
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
   251
    Mixed mode arithmetic:
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   252
	longFloat op longFloat   -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   253
	longFloat op fix         -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   254
	longFloat op fraction    -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   255
	longFloat op integer     -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   256
	longFloat op shortFloat  -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   257
	longFloat op float       -> longFloat
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   258
	longFloat op complex     -> complex
21973
d81790350a50 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21971
diff changeset
   259
d81790350a50 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21971
diff changeset
   260
    Range and precision of storage formats: see LimitedPrecisionReal >> documentation
7405
9b0334a4591b comments
Claus Gittinger <cg@exept.de>
parents: 7403
diff changeset
   261
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    [author:]
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   263
	Claus Gittinger
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   264
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    [see also:]
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   266
	Number
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   267
	Float ShortFloat Fraction FixedPoint Integer Complex
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   268
	FloatArray DoubleArray
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   269
	https://en.wikipedia.org/wiki/Extended_precision
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
"
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
!LongFloat class methodsFor:'instance creation'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   275
basicNew
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   276
    "return a new longFloat - here we return 0.0
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
     - LongFloats are usually NOT created this way ...
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
     Its implemented here to allow things like binary store & load
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
     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
   280
     a good idea to store the bits of a float - the reader might have a
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   281
     totally different representation - so floats will eventually be
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
     binary stored in a device independent format."
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
%{  /* NOCONTEXT */
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   285
#ifdef __SCHTEAM__
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   286
    return __c__._RETURN( new STDouble(0.0) );
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   287
#else
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   289
    if (sizeof(LONGFLOAT_t) == sizeof(double)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   290
	__qMKFLOAT(newFloat, 0.0);   /* OBJECT ALLOCATION */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   291
    } else {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   292
	__qMKLFLOAT(newFloat, 0.0);   /* OBJECT ALLOCATION */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   293
    }
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    RETURN (newFloat);
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   295
#endif /* not SCHTEAM */
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
%}
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   299
fastFromString:aString at:startIndex
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   300
    "return the next LongFloat from the string starting at startIndex.
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   301
     No spaces are skipped.
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   302
     Raises an exception, if the startIndex is not valid.
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   303
     Returns garbage if the argument string is not a valid double float number.
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   304
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   305
     This is a specially tuned entry (using a low-level C-call to strtold).
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   306
     It has been added to allow high speed string decomposition
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   307
     into numbers, especially for mass-data (reading millions of floats)."
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   308
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   309
%{   /* NOCONTEXT */
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   310
     int idx = __intVal(startIndex) - 1;
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   311
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   312
     if (__isStringLike(aString) && __isSmallInteger(startIndex)) {
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   313
	char *cp = (char *)(__stringVal(aString));
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   314
	OBJ newFloat;
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   315
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   316
	if ((unsigned)idx < __stringSize(aString)) {
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   317
#ifndef NO_STRTOLD
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   318
	    long double strtold(const char *, char**);
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   319
	    LONGFLOAT_t val = strtold(cp+idx, NULL);
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   320
#else
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   321
# ifndef NO_SSCANF_LONGFLOAT
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   322
	    LONGFLOAT_t val;
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   323
	    sscanf(cp+idx, "%Lf", &val);
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   324
# else
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   325
	    __qMKLFLOAT(newFloat, val);
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   326
	    RETURN (newFloat);
24989
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   327
# endif
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   328
#endif
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   329
	}
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   330
     }
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   331
%}.
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   332
     ^ self readFromString:(startIndex == 1 ifTrue:[aString] ifFalse:[aString from:startIndex])
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   333
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   334
    "
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   335
     LongFloat fastFromString:'123.45' at:1
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   336
     LongFloat fastFromString:'123.45' at:2
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   337
     LongFloat fastFromString:'123.45' at:3
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   338
     LongFloat fastFromString:'123.45' at:4
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   339
     LongFloat fastFromString:'123.45' at:5
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   340
     LongFloat fastFromString:'123.45' at:6
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   341
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   342
     LongFloat fastFromString:'123.45E4' at:1
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   343
     LongFloat fastFromString:'hello123.45E4' at:6
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   344
     LongFloat fastFromString:'12345' at:1
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   345
     LongFloat fastFromString:'12345' at:2
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   346
     LongFloat fastFromString:'12345' at:3
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   347
     LongFloat fastFromString:'12345' at:4
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   348
     LongFloat fastFromString:'12345' at:5
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   349
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   350
     LongFloat fastFromString:'12345' at:6          -> error
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   351
     LongFloat fastFromString:'12345' at:0          -> error
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   352
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   353
     LongFloat fastFromString:'hello123.45E4' at:1  -> 0
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   354
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   355
     LongFloat fastFromString:'1.7976931348623157e+308'
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   356
     LongFloat fastFromString:'Nan'
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   357
     LongFloat fastFromString:'+Inf'
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   358
     LongFloat fastFromString:'-Inf'
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   359
    "
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   360
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   361
    "
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   362
     Time millisecondsToRun:[
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   363
	1000000 timesRepeat:[
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   364
	    LongFloat readFrom:'123.45'
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   365
	]
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   366
     ]
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   367
    "
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   368
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   369
    "
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   370
     Time millisecondsToRun:[
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   371
	1000000 timesRepeat:[
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   372
	    LongFloat fastFromString:'123.45' at:1
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   373
	]
24973
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   374
     ]
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   375
    "
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   376
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   377
    "Modified (comment): / 21-06-2017 / 09:24:32 / cg"
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   378
    "Modified (comment): / 20-03-2019 / 13:45:12 / Claus Gittinger"
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   379
!
514048473232 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24965
diff changeset
   380
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   381
fromFloat:aFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   382
    "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
   383
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   384
%{  /* NOCONTEXT */
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   385
#ifdef __SCHTEAM__
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   386
    if (aFloat.isDouble()) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   387
	return __c__._RETURN(aFloat);
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   388
    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   389
    if (aFloat.isFloat()) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   390
	return __c__._RETURN( new STDouble(aFloat.floatValue()) );
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   391
    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   392
#else
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   393
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   394
    LONGFLOAT_t f;
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   395
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   396
    if (sizeof(LONGFLOAT_t) == sizeof(double)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   397
	RETURN (aFloat);
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   398
    }
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   399
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   400
    if (__isFloatLike(aFloat)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   401
	f = (LONGFLOAT_t)(__floatVal(aFloat));
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   402
	__qMKLFLOAT(newFloat, f);   /* OBJECT ALLOCATION */
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   403
	RETURN (newFloat);
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   404
    }
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   405
#endif
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   406
%}.
24275
1de47e7b0e9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24267
diff changeset
   407
    ArgumenError raise
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   408
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   409
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   410
     LongFloat fromFloat:123.0
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   411
     123.0 asLongFloat
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   412
     123 asLongFloat
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   413
    "
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   414
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   415
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   416
fromIEEE32Bit: anInteger
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   417
    "creates a long float, given the four native float bytes as an integer"
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   418
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   419
%{  /* NOCONTEXT */
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   420
    OBJ newFloat;
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   421
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   422
    REGISTER union {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   423
	unsigned int    i;
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   424
	float           f;
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   425
    } r;
24989
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   426
    LONGFLOAT_t f;
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   427
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   428
    r.i = __unsignedLongIntVal( anInteger );
24989
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   429
    f = (LONGFLOAT_t)r.f;
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   430
    __qMKLFLOAT(newFloat, f);
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   431
    RETURN( newFloat );
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   432
%}.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   433
    ^ Float fromIEEE32Bit: anInteger
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   434
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   435
    "
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   436
     LongFloat fromIEEE32Bit:((ShortFloat pi digitBytesMSB:true) asIntegerMSB:true)
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   437
    "
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   438
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   439
    "Modified: / 21-06-2017 / 09:35:58 / cg"
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   440
!
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   441
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   442
fromIEEE64Bit: anInteger
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   443
    "creates a long double, given the eight native double bytes as an integer"
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   444
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   445
%{  /* NOCONTEXT */
19268
6711c095d091 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19267
diff changeset
   446
    extern int __unsignedLong64IntVal(OBJ o, __uint64__ *pI);
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   447
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   448
    REGISTER union {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   449
	__uint64__  u64;
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   450
	double      d;
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   451
    } r;
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   452
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   453
    if (__unsignedLong64IntVal(anInteger, &r.u64))  {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   454
	OBJ newFloat;
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   455
	LONGFLOAT_t f = (LONGFLOAT_t)r.d;
24989
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   456
98c3a2fa1757 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24985
diff changeset
   457
	__qMKLFLOAT(newFloat, f);
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   458
	RETURN( newFloat );
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   459
    }
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   460
%}.
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   461
    ^ Float fromIEEE32Bit: anInteger
17584
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   462
797b3233c6ef class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17459
diff changeset
   463
    "
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   464
	LongFloat fromIEEE64Bit:((Float pi digitBytesMSB:true) asIntegerMSB:true)
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   465
    "
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   466
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   467
    "Modified (comment): / 21-06-2017 / 09:36:34 / cg"
17219
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   468
!
38228cd1e2a2 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17129
diff changeset
   469
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   470
fromInteger:anInteger
19360
5b112fdb68be #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19356
diff changeset
   471
    "return a new longFloat, given an integer value"
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   472
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   473
%{  /* NOCONTEXT */
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   474
#ifdef __SCHTEAM__
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   475
    if (anInteger.isSmallInteger()) {
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   476
	return __c__._RETURN( STDouble._new( (double)(anInteger.longValue()) ));
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   477
    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   478
#else
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   479
    OBJ newFloat;
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   480
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   481
    if (__isSmallInteger(anInteger)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   482
	LONGFLOAT_t f = (LONGFLOAT_t)__smallIntegerVal(anInteger);
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   483
	__qMKLFLOAT(newFloat, f);   /* OBJECT ALLOCATION */
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   484
	RETURN (newFloat);
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   485
    }
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   486
#endif /* not SCHTEAM */
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   487
%}.
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   488
    ^ super fromInteger:anInteger
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   489
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   490
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   491
     LongFloat fromInteger:123
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   492
     LongFloat fromInteger:(100 factorial)
19360
5b112fdb68be #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19356
diff changeset
   493
     (100 factorial) asLongFloat
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   494
    "
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   495
!
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
fromShortFloat:aFloat
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   498
    "return a new longFloat, given a shortFloat value"
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   499
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   500
%{  /* NOCONTEXT */
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   501
#ifdef __SCHTEAM__
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   502
    if (aFloat.isFloat()) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   503
	return __c__._RETURN( new STDouble(aFloat.floatValue()) );
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   504
    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   505
    if (aFloat.isDouble()) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   506
	return __c__._RETURN( aFloat );
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   507
    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   508
#else
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   509
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   510
    LONGFLOAT_t f;
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
    if (__isShortFloat(aFloat)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   513
	f = (LONGFLOAT_t)(__shortFloatVal(aFloat));
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   514
	__qMKLFLOAT(newFloat, f);   /* OBJECT ALLOCATION */
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
   515
	RETURN (newFloat);
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   516
    }
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
   517
#endif /* not SCHTEAM */
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   518
%}.
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   519
    self error:'invalid argumnet'
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   520
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   521
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   522
     LongFloat fromShortFloat:(123.0 asShortFloat)
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   523
     LongFloat fromShortFloat:122
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   524
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
12914
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   527
!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
   528
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   529
defaultPrintFormat
24952
79fc76e963a3 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24948
diff changeset
   530
    "/ by default, I will print 19 digits
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   531
    "/  ShortFloat pi   -> 3.141593
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   532
    "/  Float pi        -> 3.14159265358979
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   533
    "/  LongFloat pi    -> 3.141592653589793239
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   534
    "/  QuadFloat pi    -> 3.141592653589793239
24952
79fc76e963a3 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24948
diff changeset
   535
12914
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   536
    ^ DefaultPrintFormat
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   537
!
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   538
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   539
defaultPrintFormat:something
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   540
    DefaultPrintFormat := something.
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   541
! !
802070da5c65 #printString prints with maximum precision (15 for Float and 19 for LongFloat)
Stefan Vogel <sv@exept.de>
parents: 12476
diff changeset
   542
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   543
!LongFloat class methodsFor:'class initialization'!
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   544
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   545
initialize
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   546
    DefaultPrintFormat := '.19'.  "/ 19 valid digits
21868
f568817ef1d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21857
diff changeset
   547
    DefaultPrintfFormat := '%19f'.
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   548
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   549
    "
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   550
     self initialize
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   551
    "
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   552
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   553
    "
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   554
     DefaultPrintFormat := '.19'.
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   555
     LongFloat pi printString.
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   556
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   557
     DefaultPrintFormat := '.9'.
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   558
     LongFloat pi printString.
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   559
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   560
     DefaultPrintFormat := '.6'.
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   561
     LongFloat pi printString.
7448
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   562
    "
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   563
! !
d1aaa52b463e double dispatching, printing NaN and INF
Claus Gittinger <cg@exept.de>
parents: 7417
diff changeset
   564
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   565
!LongFloat class methodsFor:'coercing & converting'!
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   566
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   567
coerce:aNumber
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   568
    "convert the argument aNumber into an instance of the receiver (class) and return it."
21874
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   569
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   570
    ^ aNumber asLongFloat.
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   571
! !
6edca189ad56 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21869
diff changeset
   572
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
!LongFloat class methodsFor:'constants'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   575
NaN
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   576
    "return a longFloat which represents not-a-Number (i.e. an invalid number)"
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   577
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   578
    NaN isNil ifTrue:[
21868
f568817ef1d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21857
diff changeset
   579
	NaN := super NaN
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   580
    ].
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   581
    ^ NaN
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   582
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   583
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   584
     LongFloat NaN
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   585
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   586
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   587
    "Created: / 20-06-2017 / 13:52:58 / cg"
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   588
!
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   589
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   590
e
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   591
    "return the constant e as LongFloat"
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   592
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   593
    E isNil ifTrue:[
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   594
	"/ eDigits has enough digits for 128bit IEEE quads
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   595
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   596
	E  := self readFrom:(Number eDigits)
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   597
    ].
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   598
    ^ E
24263
9b19f063bb70 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24255
diff changeset
   599
9b19f063bb70 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24255
diff changeset
   600
    "Modified (format): / 06-06-2019 / 17:02:27 / Claus Gittinger"
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   601
!
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   602
22724
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   603
halfpi
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   604
    "return the constant pi/2 as LongFloat"
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   605
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   606
    Halfpi isNil ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   607
	"/ enough digits for 128bit IEEE quads
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   608
	"/ do not write as a literal constant here - we cannot depend on the underlying C-compiler here...
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   609
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   610
	Halfpi := (self readFrom:'1.570796326794896619231321691639751442098584699687552910').
22724
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   611
    ].
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   612
    ^ Halfpi
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   613
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   614
    "
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   615
     self halfpi
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   616
    "
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   617
!
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   618
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   619
halfpiNegative
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   620
    "return the constant -pi/2 as LongFloat"
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   621
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   622
    HalfpiNegative isNil ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
   623
	HalfpiNegative := (self readFrom:'-1.570796326794896619231321691639751442098584699687552910')
22724
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   624
    ].
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   625
    ^ HalfpiNegative
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   626
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   627
    "
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   628
     self halfpiNegative
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   629
    "
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   630
!
ccdb7155bb8a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   631
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   632
infinity
24305
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   633
    "return a longFloat which represents positive infinity (for my instances).
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   634
     Warning: do not compare equal against infinities;
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   635
     instead, check using isFinite or isInfinite"
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   636
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   637
    PositiveInfinity isNil ifTrue:[
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
   638
	PositiveInfinity := Float infinity asLongFloat
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   639
    ].
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   640
    ^ PositiveInfinity
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   641
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   642
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   643
     LongFloat infinity
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   644
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   645
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   646
    "Created: / 20-06-2017 / 13:53:45 / cg"
24305
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   647
    "Modified (comment): / 09-06-2019 / 12:52:58 / Claus Gittinger"
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   648
!
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   649
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   650
negativeInfinity
24305
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   651
    "return a longFloat which represents positive infinity (for my instances).
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   652
     Warning: do not compare equal against infinities;
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   653
     instead, check using isFinite or isInfinite"
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   654
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   655
    NegativeInfinity isNil ifTrue:[
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
   656
	NegativeInfinity := Float negativeInfinity asLongFloat
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   657
    ].
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   658
    ^ NegativeInfinity
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   659
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   660
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   661
     LongFloat negativeInfinity
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   662
    "
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   663
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   664
    "Created: / 20-06-2017 / 13:54:19 / cg"
24305
3666b6373fb9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24292
diff changeset
   665
    "Modified (comment): / 09-06-2019 / 12:53:25 / Claus Gittinger"
21857
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   666
!
76798ae913d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21851
diff changeset
   667
24932
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   668
phi
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   669
    "return the constant phi as LongFloat"
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   670
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   671
    Phi isNil ifTrue:[
24985
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   672
	"/ phiDigits has enough digits for 128bit IEEE quads
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   673
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
25eacb3088ee #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24973
diff changeset
   674
	Phi := self readFrom:(Number phiDigits)
24932
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   675
    ].
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   676
    ^ Phi
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   677
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   678
    "Modified (format): / 06-06-2019 / 17:10:22 / Claus Gittinger"
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   679
!
606ca39a5e38 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24818
diff changeset
   680
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   681
pi
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   682
    "return the constant pi as LongFloat"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   684
    Pi isNil ifTrue:[
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   685
	"/ piDigits has enough digits for 128bit IEEE quads
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   686
	"/ do not use as a literal constant here - we cannot depend on the underlying C-compiler here...
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   687
	Pi := self readFrom:(Number piDigits)
19570
017c53457288 lazy computation of epsilon
Claus Gittinger <cg@exept.de>
parents: 19360
diff changeset
   688
    ].
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
   689
    ^ Pi
24263
9b19f063bb70 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24255
diff changeset
   690
9b19f063bb70 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24255
diff changeset
   691
    "Modified (format): / 06-06-2019 / 17:10:22 / Claus Gittinger"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   694
unity
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   695
    "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
   696
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   697
    LongFloatOne isNil ifTrue:[
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
   698
	LongFloatOne := 1.0 asLongFloat.
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   699
    ].
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   700
    ^ LongFloatOne
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
    "Modified: 23.4.1996 / 09:26:51 / cg"
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   705
zero
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   706
    "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
   707
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   708
    LongFloatZero isNil ifTrue:[
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
   709
	LongFloatZero := 0.0 asLongFloat
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   710
    ].
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   711
    ^ LongFloatZero
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
    "Modified: 23.4.1996 / 09:26:45 / cg"
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
!LongFloat class methodsFor:'queries'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
21826
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   718
defaultPrintPrecision
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   719
    "return the number of decimal digits printed by default"
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   720
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   721
    ^ DefaultPrintPrecision ? 8
21826
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   722
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   723
    "
24292
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
   724
     LongFloat defaultPrintPrecision
21868
f568817ef1d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21857
diff changeset
   725
     ShortFloat defaultPrintPrecision
f568817ef1d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21857
diff changeset
   726
     Float defaultPrintPrecision
21826
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   727
    "
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   728
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   729
    "Created: / 17-06-2017 / 02:58:42 / cg"
24292
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
   730
    "Modified (comment): / 08-06-2019 / 14:33:50 / Claus Gittinger"
21826
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   731
!
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
   732
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   733
emax
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   734
    "The largest exponent value allowed by instances of this class."
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   735
25022
391997c035aa #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 25013
diff changeset
   736
    ^ 16383
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   737
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   738
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   739
     1.0 asLongFloat fmax  -> 1.189731495357231765E+4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   740
     1.0 asLongFloat fmin  -> 3.362103143112093506E-4932
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   741
     1.0 asLongFloat emin  -> -16382
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   742
     1.0 asLongFloat emax  -> 16383
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   743
     1.0 asLongFloat eBias -> 16383
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   744
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   745
!
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   746
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   747
emin
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   748
    "The smallest exponent value allowed by instances of this class."
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   749
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   750
    ^ -16382
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   751
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   752
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   753
     1.0 asLongFloat fmax  -> 1.189731495357231765E+4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   754
     1.0 asLongFloat fmin  -> 3.362103143112093506E-4932
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   755
     1.0 asLongFloat emin  -> -16382
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   756
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   757
!
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   758
24321
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   759
epsilon
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   760
    "return the maximum relative spacing of instances of mySelf
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   761
     (i.e. the value-delta of the least significant bit)"
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   762
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   763
    Epsilon isNil ifTrue:[
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   764
	Epsilon := self computeEpsilon.
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   765
    ].
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   766
    ^ Epsilon
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   767
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   768
    "Modified (comment): / 21-06-2017 / 13:57:03 / cg"
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   769
    "Modified (comment): / 10-05-2018 / 01:09:07 / stefan"
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   770
!
c1488d3bdbdc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24305
diff changeset
   771
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   772
exponentCharacter
24325
ecf41f481591 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24321
diff changeset
   773
    "return the character used to print between mantissa an exponent.
ecf41f481591 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24321
diff changeset
   774
     Also used by the scanner when reading numbers."
ecf41f481591 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24321
diff changeset
   775
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   776
    ^ $q
24325
ecf41f481591 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24321
diff changeset
   777
ecf41f481591 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24321
diff changeset
   778
    "Modified (comment): / 10-06-2019 / 21:27:49 / Claus Gittinger"
6898
d0182256f3ff *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6574
diff changeset
   779
!
d0182256f3ff *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6574
diff changeset
   780
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   781
fmax
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   782
    "The largest value allowed by instances of this class."
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   783
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   784
%{  /* NOCONTEXT */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   785
#if defined(LDBL_MAX) && !defined(__BORLANDC__)
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   786
    {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   787
	OBJ newFloat;
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   788
	__qMKLFLOAT(newFloat, LDBL_MAX);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   789
	RETURN(newFloat);
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   790
    }
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   791
#endif
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   792
%}.
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   793
    ^ super fmax
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   794
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   795
    "
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   796
     1.0 asLongFloat fmax  -> 1.189731495357231765E+4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   797
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   798
!
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   799
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   800
fmin
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   801
    "The smallest non-zero value allowed by instances of this class."
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   802
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   803
%{  /* NOCONTEXT */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   804
#if defined(LDBL_MIN) && !defined(__BORLANDC__)
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   805
    {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   806
	OBJ newFloat;
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   807
	__qMKLFLOAT(newFloat, LDBL_MIN);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   808
	RETURN(newFloat);
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   809
    }
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   810
#endif
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   811
%}.
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   812
    ^ super fmin
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   813
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   814
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   815
     1.0 asLongFloat fmax  -> 1.189731495357231765E+4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   816
     1.0 asLongFloat fmin  -> 3.362103143112093506E-4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   817
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   818
!
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   819
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   820
isBuiltInClass
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   821
    "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
   822
     Here, true is returned for myself, false for subclasses."
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
    ^ self == LongFloat
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    "Modified: 23.4.1996 / 16:00:23 / cg"
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   829
numBitsInExponent
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   830
    "answer the number of bits in the exponent
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   831
     i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   832
	   where 15 bits are available in the exponent (i bit is ignored):
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   833
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
15327
0615616bb8da class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 15313
diff changeset
   834
     x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   835
	   where 15 bits are available in the exponent:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   836
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   837
     sparc & others: This is an 128bit longfloat,
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   838
	   where 15 bits are available in the exponent:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   839
	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm 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
   840
    "
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   841
%{  /* NOCONTEXT */
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   842
#if defined(__x86__) || defined(__x86_64__)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   843
    if (sizeof(LONGFLOAT_t) == 10) {      /* x86 - WIN32: 80bit floats */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   844
	RETURN (__mkSmallInteger(15));
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   845
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   846
    if (sizeof(LONGFLOAT_t) == 12) {      /* x86 - some unixes: 96bit floats */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   847
	RETURN (__mkSmallInteger(15));
7413
9c78545361b3 more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents: 7405
diff changeset
   848
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   849
    if (sizeof(LONGFLOAT_t) == 16) {      /* amd64, x86_64 */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   850
	RETURN (__mkSmallInteger(15));
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   851
    }
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   852
#else
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   853
    if (sizeof(LONGFLOAT_t) == 16) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   854
	RETURN (__mkSmallInteger(15));  /* sparc */
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   855
    }
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   856
#endif
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   857
%}.
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   858
    "systems without longFloat support use doubles instead"
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   859
    self basicNew basicSize == Float basicNew basicSize ifTrue:[
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   860
	^ Float numBitsInExponent
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   861
    ].
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   862
    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
   863
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   864
    "
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   865
     1.0 asLongFloat numBitsInExponent -> 15
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   866
    "
24205
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   867
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   868
    "Modified (comment): / 28-05-2019 / 09:02:06 / Claus Gittinger"
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   869
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   870
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   871
numBitsInIntegerPart
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   872
    "answer the number of bits in the integer part of the mantissa.
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   873
     This will return 0 or 1; 1 if there is no hidden bit, 0 if there is.
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   874
     See https://en.wikipedia.org/wiki/Extended_precision.
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   875
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   876
     i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   877
	   where 1 bit is used for the integer part in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   878
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
15327
0615616bb8da class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 15313
diff changeset
   879
     x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   880
	   where 1+63 bits are available in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   881
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   882
     sparc & others: This is an 128bit longfloat,
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   883
	   where 112 bits are available in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   884
	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm 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
   885
    "
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   886
%{  /* NOCONTEXT */
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   887
#if defined(__x86__) || defined(__x86_64__)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   888
    if (sizeof(LONGFLOAT_t) == 10) {      /* x86 - WIN32: 80bit floats */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   889
	RETURN (__mkSmallInteger(1));
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   890
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   891
    if (sizeof(LONGFLOAT_t) == 12) {      /* x86 - some other unixes: 96bit floats*/
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   892
	RETURN (__mkSmallInteger(1));
7413
9c78545361b3 more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents: 7405
diff changeset
   893
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   894
    if (sizeof(LONGFLOAT_t) == 16) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   895
	RETURN (__mkSmallInteger(1));   /* amd64, x86_64 */
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   896
    }
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   897
#else
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   898
    if (sizeof(LONGFLOAT_t) == 16) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   899
	RETURN (__mkSmallInteger(0));   /* sparc */
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   900
    }
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   901
#endif
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   902
%}.
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   903
    "systems without longFloat support use doubles instead"
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   904
    self basicNew basicSize == Float basicNew basicSize ifTrue:[
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   905
	^ Float numBitsInIntegerPart
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   906
    ].
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   907
    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
   908
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   909
    "
16659
6205a731485a class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 16445
diff changeset
   910
     self numBitsInIntegerPart
24205
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   911
     1.0 asLongFloat numBitsInIntegerPart
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   912
     1.0 asFloat numBitsInIntegerPart
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   913
     1.0 asShortFloat numBitsInIntegerPart
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   914
    "
24205
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   915
24470
b562735ecadc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24460
diff changeset
   916
    "Modified: / 24-07-2019 / 10:33:11 / Claus Gittinger"
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   917
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   918
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   919
numBitsInMantissa
25027
d552e6a21c22 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 25022
diff changeset
   920
    "answer the number of bits in the mantissa (the significant)
24190
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
   921
     the hidden bit is not counted here:
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
   922
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   923
     i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   924
	   where 1+63 bits are available in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   925
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
15327
0615616bb8da class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 15313
diff changeset
   926
     x86_64: This is an 80bit longfloat stored in 128 bits (upper 48 bits are unused),
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   927
	   where 1+63 bits are available in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   928
	00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   929
     sparc: This is an 128bit longfloat,
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   930
	   where 112 bits are available in the mantissa:
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   931
	seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm 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
   932
    "
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   933
%{  /* NOCONTEXT */
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
   934
#if defined(__x86__) || defined(__x86_64__)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   935
    if (sizeof(LONGFLOAT_t) == 10) {      /* x86 - WIN32: 80bit */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   936
	RETURN (__mkSmallInteger(64));
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   937
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   938
    if (sizeof(LONGFLOAT_t) == 12) {      /* x86 some unixes: 96bit */
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   939
	RETURN (__mkSmallInteger(64));
7413
9c78545361b3 more LongFloat definitions for Win32
Claus Gittinger <cg@exept.de>
parents: 7405
diff changeset
   940
    }
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   941
    if (sizeof(LONGFLOAT_t) == 16) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   942
	RETURN (__mkSmallInteger(64));  /* amd64, x86_64 */
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   943
    }
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   944
#else
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   945
    if (sizeof(LONGFLOAT_t) == 16) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   946
	RETURN (__mkSmallInteger(112)); /* sparc */
16780
f5458df271ed class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 16662
diff changeset
   947
    }
15263
06bf31b1a170 osx fixes
Claus Gittinger <cg@exept.de>
parents: 15021
diff changeset
   948
#endif
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   949
%}.
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   950
    "systems without longFloat support use doubles instead"
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   951
    self basicNew basicSize == Float basicNew basicSize ifTrue:[
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   952
	^ Float numBitsInMantissa
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   953
    ].
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   954
    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
   955
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   956
    "
19329
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
   957
     1.0 class numBitsInMantissa
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
   958
     1.0 asShortFloat class numBitsInMantissa
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
   959
     1.0 asLongFloat class numBitsInMantissa
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   960
    "
24190
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
   961
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   962
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   963
     1.0 asLongFloat numBitsInExponent 15
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   964
     1.0 asLongFloat numBitsInMantissa 64
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   965
     1.0 asLongFloat precision         64
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   966
     1.0 asLongFloat decimalPrecision  19
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   967
     1.0 asLongFloat eBias             16383
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   968
     1.0 asLongFloat emin              -16382
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   969
     1.0 asLongFloat emax              16383
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
   970
     1.0 asLongFloat fmin
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   971
     1.0 asLongFloat fmax              1.189731495357231765E+4932
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   972
    "
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
   973
24190
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
   974
    "Modified: / 27-05-2019 / 15:28:04 / Claus Gittinger"
24205
72fcabd537db #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24190
diff changeset
   975
    "Modified (comment): / 28-05-2019 / 09:02:36 / Claus Gittinger"
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   976
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   977
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   978
radix
24438
dfad57d7c9ad #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24329
diff changeset
   979
   "answer the radix of a LongFloat's exponent
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
   980
    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
   981
8635
38674ba49a14 comment
Claus Gittinger <cg@exept.de>
parents: 8422
diff changeset
   982
    ^ 2 "must be careful here, whenever ST/X is used on VAX or a 370"
24438
dfad57d7c9ad #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24329
diff changeset
   983
dfad57d7c9ad #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24329
diff changeset
   984
    "Modified (comment): / 19-07-2019 / 17:28:16 / Claus Gittinger"
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
!LongFloat methodsFor:'arithmetic'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
   989
* aNumber
11729
7be800aefa39 comment
Claus Gittinger <cg@exept.de>
parents: 11719
diff changeset
   990
    "return the product of the receiver and the argument."
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
%{  /* NOCONTEXT */
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
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   995
    LONGFLOAT_t result, val;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
   998
	val = (LONGFLOAT_t)(__intVal(aNumber));
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
   999
doMul:
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1000
	result = __longFloatVal(self) * val;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1001
	__qMKLFLOAT(newFloat, result);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1002
	RETURN ( newFloat );
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1003
    }
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1004
    if (aNumber != nil) {
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1005
	if (__qIsLongFloat(aNumber)) {
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1006
	    val = __longFloatVal(aNumber);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1007
	    goto doMul;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1008
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1009
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1010
	    val = (LONGFLOAT_t)(__floatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1011
	    goto doMul;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1012
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1013
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1014
	    val = (LONGFLOAT_t)(__shortFloatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1015
	    goto doMul;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1016
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    ^ aNumber productFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1022
+ aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1023
    "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
  1024
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1027
    LONGFLOAT_t result, val;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1030
	val = (LONGFLOAT_t)(__intVal(aNumber));
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1031
doAdd:
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1032
	result = __longFloatVal(self) + val;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1033
	__qMKLFLOAT(newFloat, result);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1034
	RETURN ( newFloat );
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1035
    }
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1036
    if (aNumber != nil) {
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1037
	if (__qIsLongFloat(aNumber)) {
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1038
	    val = __longFloatVal(aNumber);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1039
	    goto doAdd;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1040
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1041
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1042
	    val = (LONGFLOAT_t)(__floatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1043
	    goto doAdd;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1044
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1045
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1046
	    val = (LONGFLOAT_t)(__shortFloatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1047
	    goto doAdd;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1048
	}
4165
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
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
    ^ aNumber sumFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1054
- aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1055
    "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
  1056
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1060
    LONGFLOAT_t result, val;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1063
	val = (LONGFLOAT_t)(__intVal(aNumber));
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1064
doSub:
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1065
	result = __longFloatVal(self) - val;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1066
	__qMKLFLOAT(newFloat, result);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1067
	RETURN ( newFloat );
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1068
    }
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1069
    if (aNumber != nil) {
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1070
	if (__qIsLongFloat(aNumber)) {
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1071
	    val = __longFloatVal(aNumber);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1072
	    goto doSub;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1073
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1074
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1075
	    val = (LONGFLOAT_t)(__floatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1076
	    goto doSub;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1077
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1078
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1079
	    val = (LONGFLOAT_t)(__shortFloatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1080
	    goto doSub;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1081
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    ^ aNumber differenceFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1087
/ aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1088
    "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
  1089
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
%{  /* NOCONTEXT */
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
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1093
    LONGFLOAT_t result, val;
4165
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
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1096
	val = (LONGFLOAT_t)(__intVal(aNumber));
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1097
doDiv:
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1098
	if (val == 0.0) goto badArg;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1099
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1100
	result = __longFloatVal(self) / val;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1101
	__qMKLFLOAT(newFloat, result);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1102
	RETURN ( newFloat );
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1103
    }
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1104
    if (aNumber != nil) {
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1105
	if (__qIsLongFloat(aNumber)) {
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1106
	    val = __longFloatVal(aNumber);
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1107
	    goto doDiv;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1108
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1109
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1110
	    val = (LONGFLOAT_t)(__floatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1111
	    goto doDiv;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1112
	}
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1113
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1114
	    val = (LONGFLOAT_t)(__shortFloatVal(aNumber));
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1115
	    goto doDiv;
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1116
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    }
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1118
badArg: ;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
    ((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
  1121
	"
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1122
	 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
  1123
	"
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  1124
	^ ZeroDivide raiseRequestWith:thisContext.
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
    ].
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    ^ aNumber quotientFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1129
abs
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1130
    "return the absolute value of the receiver
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1131
     reimplemented here for speed"
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1132
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1133
%{  /* NOCONTEXT */
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1134
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1135
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1136
    LONGFLOAT_t val = __longFloatVal(self);
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1137
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1138
    if (val < (LONGFLOAT_t)0.0) {
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1139
	__qMKLFLOAT(newFloat, -val);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1140
	RETURN ( newFloat );
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1141
    }
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1142
    RETURN (self);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1143
%}.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1144
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1145
    "
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1146
     3.0 asLongFloat abs
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1147
     -3.0 asLongFloat abs
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1148
    "
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1149
!
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1150
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1151
negated
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1152
    "return myself negated"
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1153
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1154
%{  /* NOCONTEXT */
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1155
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1156
    LONGFLOAT_t rslt = - __longFloatVal(self);
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1157
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1158
    __qMKLFLOAT(newFloat, rslt);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1159
    RETURN ( newFloat );
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1160
%}.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1161
!
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  1162
14691
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1163
rem: aNumber
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1164
    "return the floating point remainder of the receiver and the argument, aNumber"
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1165
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1166
%{  /* NOCONTEXT */
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1167
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1168
    /*
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1169
     * notice:
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1170
     * the following inline code handles some common cases,
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1171
     * and exists as an optimization, to speed up those cases.
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1172
     *
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1173
     * Conceptionally, (and for most other argument types),
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1174
     * mixed arithmetic is implemented by double dispatching
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1175
     * (see the message send at the bottom)
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1176
     */
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1177
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1178
    LONGFLOAT_t result, val;
14691
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1179
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1180
    if (__isSmallInteger(aNumber)) {
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1181
	if (aNumber != __mkSmallInteger(0)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1182
	    val = (LONGFLOAT_t)__intVal(aNumber);
14691
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1183
	    if (val == 0.0) goto badArg;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1184
computeResult:
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1185
	    result = fmodl(__longFloatVal(self), val) ;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1186
	    __qMKLFLOAT(newFloat, result);
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1187
	    RETURN ( newFloat );
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1188
	}
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1189
    } else if (__isFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1190
	val = (LONGFLOAT_t)__floatVal(aNumber);
14691
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1191
	goto computeResult;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1192
    } else if (__isShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1193
	val = (LONGFLOAT_t)__shortFloatVal(aNumber);
14691
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1194
	goto computeResult;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1195
    } else if (__isLongFloat(aNumber)) {
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1196
	val = __longFloatVal(aNumber);
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1197
	goto computeResult;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1198
    }
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1199
badArg: ;
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1200
%}.
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1201
    ((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1202
	"
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1203
	 No, you shalt not divide by zero
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1204
	"
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1205
	^ ZeroDivide raiseRequestWith:thisContext.
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1206
    ].
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1207
    ^ aNumber remainderFromLongFloat:self
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1208
!
ba94000e28b2 added rem:
Claus Gittinger <cg@exept.de>
parents: 14673
diff changeset
  1209
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1210
uncheckedDivide:aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1211
    "return the quotient of the receiver and the argument, aNumber.
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7448
diff changeset
  1212
     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
  1213
     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
  1214
     where no exception is raised for these results (i.e. Java).
18842
c57fb2395d74 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18833
diff changeset
  1215
     It is only defined if the argument's type is the same as the receiver's."
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1220
    LONGFLOAT_t result, val;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1223
	val = (LONGFLOAT_t)(__intVal(aNumber));
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1224
doDiv:
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1225
	result = __longFloatVal(self) / val;
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1226
	__qMKLFLOAT(newFloat, result);
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1227
	RETURN ( newFloat );
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1228
    }
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1229
    if (aNumber != nil) {
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1230
	if (__qIsLongFloat(aNumber)) {
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1231
	    val = __longFloatVal(aNumber);
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1232
	    goto doDiv;
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1233
	}
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1234
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1235
	    val = (LONGFLOAT_t)(__shortFloatVal(aNumber));
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1236
	    goto doDiv;
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1237
	}
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1238
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1239
	    val = (LONGFLOAT_t)(__floatVal(aNumber));
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1240
	    goto doDiv;
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1241
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
    ^ aNumber quotientFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
      0.0 asLongFloat uncheckedDivide:0
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
      1.0 asLongFloat uncheckedDivide:0.0
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1249
      -1.0 asLongFloat uncheckedDivide:0.0
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
5257
a90fd9cb3c18 category rename
Claus Gittinger <cg@exept.de>
parents: 5120
diff changeset
  1253
!LongFloat methodsFor:'coercing & converting'!
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1254
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1255
asFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1256
    "return a Float with same value as the receiver.
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1257
     Raises an error if the receiver exceeds the float range."
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1262
    LONGFLOAT_t lVal = __longFloatVal(self);
24255
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1263
    double dVal = (double)lVal;
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1264
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1265
    if (isfinite(dVal) || !isfinite(lVal)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1266
	__qMKFLOAT(newFloat, dVal);
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1267
	RETURN ( newFloat );
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1268
    }
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1269
%}.
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1270
    "
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1271
     value out of range
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1272
     if you need -INF for a zero receiver, try Number trapInfinity:[...]
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1273
    "
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1274
    ^ self class
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1275
	raise:#infiniteResultSignal
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1276
	receiver:self
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1277
	selector:#asFloat
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1278
	arguments:#()
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1279
	errorString:'receiver is out of the double-precision float range'
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1282
     1.0 asLongFloat
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
    "
24292
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
  1284
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
  1285
    "Modified: / 08-06-2019 / 14:33:10 / Claus Gittinger"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1288
asInteger
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1289
    "return an integer with same value - might truncate"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
%{  /* NOCONTEXT */
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1292
    LONGFLOAT_t fVal;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
    fVal = __longFloatVal(self);
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1295
    if (!LONG_isnan(fVal) && (fVal >= (LONGFLOAT_t)_MIN_INT) && (fVal <= (LONGFLOAT_t)_MAX_INT)) {
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1296
	RETURN ( __mkSmallInteger( (INT)fVal) );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
    ^ super asInteger
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
     12345.0 asLongFloat asInteger
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
     1e15 asLongFloat asInteger
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1307
asLongFloat
15021
e0ca9bd75f0f class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 14931
diff changeset
  1308
    "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
  1309
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
    ^ self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1313
asShortFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1314
    "return a ShortFloat with same value as the receiver.
24292
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
  1315
     Raises an error if the receiver exceeds the short float range."
4455
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1316
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1317
%{  /* NOCONTEXT */
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1318
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1319
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1320
    LONGFLOAT_t lVal = __longFloatVal(self);
24255
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1321
    float fVal = (float)lVal;
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1322
82a37ed5a27c oops - converting NaN
Claus Gittinger <cg@exept.de>
parents: 24249
diff changeset
  1323
    if (isfinite(fVal) || !isfinite(lVal)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1324
	__qMKSFLOAT(newFloat, fVal);
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1325
	RETURN ( newFloat );
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1326
    }
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1327
%}.
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1328
    "
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1329
     value out of range
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1330
     if you need -INF for a zero receiver, try Number trapInfinity:[...]
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1331
    "
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1332
    ^ self class
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1333
	raise:#infiniteResultSignal
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1334
	receiver:self
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1335
	selector:#asShortFloat
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1336
	arguments:#()
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1337
	errorString:'receiver is out of the single-precision float range'
4455
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1338
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1339
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1340
     1.0 asLongFloat asShortFloat
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1341
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1342
     out of range:
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1343
	3.5028234664e+38 asShortFloat
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  1344
	-3.5028234664e+38 asShortFloat
4455
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1345
    "
24292
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
  1346
0c0ef0b76a74 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24285
diff changeset
  1347
    "Modified: / 08-06-2019 / 14:33:23 / Claus Gittinger"
4455
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1348
!
2d31d0d986be Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents: 4305
diff changeset
  1349
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1350
coerce:aNumber
18833
60ea69618028 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18363
diff changeset
  1351
    "convert the argument aNumber into an instance of the receiver's class and return it."
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1352
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1353
    ^ aNumber asLongFloat
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1354
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1355
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1356
generality
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1357
    "return the generality value - see ArithmeticValue>>retry:coercing:"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
    ^ 90
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
!LongFloat methodsFor:'comparing'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1364
< aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1365
    "return true, if the argument is greater"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1370
	RETURN ( (__longFloatVal(self) < (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1372
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1373
	if (__qIsLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1374
	    RETURN ( (__longFloatVal(self) < __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1375
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1376
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1377
	    RETURN ( (__longFloatVal(self) < (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1378
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1379
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1380
	    RETURN ( (__longFloatVal(self) < (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1381
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
    ^ aNumber lessFromLongFloat:self
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
     1.0 asLongFloat > (1/3)
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
     1.0 asLongFloat > (1/3) asLongFloat
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1392
<= aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1393
    "return true, if the argument is greater or equal"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1398
	RETURN ( (__longFloatVal(self) <= (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1400
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1401
	if (__qIsLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1402
	    RETURN ( (__longFloatVal(self) <= __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1403
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1404
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1405
	    RETURN ( (__longFloatVal(self) <= (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1406
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1407
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1408
	    RETURN ( (__longFloatVal(self) <= (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1409
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
    ^ self retry:#<= coercing:aNumber
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1415
= aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1416
    "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
  1417
     as the receiver, false otherwise"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1422
	RETURN ( (__longFloatVal(self) == (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1424
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1425
	if (__qIsLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1426
	    RETURN ( (__longFloatVal(self) == __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1427
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1428
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1429
	    RETURN ( (__longFloatVal(self) == (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1430
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1431
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1432
	    RETURN ( (__longFloatVal(self) == (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1433
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
%}.
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1436
    ^ aNumber equalFromLongFloat:self
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1439
> aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1440
    "return true, if the argument is less"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1445
	RETURN ( (__longFloatVal(self) > (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1447
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1448
	if (__qIsLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1449
	    RETURN ( (__longFloatVal(self) > __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1450
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1451
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1452
	    RETURN ( (__longFloatVal(self) > (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1453
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1454
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1455
	    RETURN ( (__longFloatVal(self) > (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1456
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
    ^ self retry:#> coercing:aNumber
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1462
>= aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1463
    "return true, if the argument is less or equal"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1467
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1468
	RETURN ( (__longFloatVal(self) >= (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1470
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1471
	if (__qIsLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1472
	    RETURN ( (__longFloatVal(self) >= __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1473
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1474
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1475
	    RETURN ( (__longFloatVal(self) >= (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1476
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1477
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1478
	    RETURN ( (__longFloatVal(self) >= (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1479
	}
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
%}.
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
    ^ self retry:#>= coercing:aNumber
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1485
hash
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1486
    "return a number for hashing; redefined, since floats compare
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
     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
  1488
     as 3 hash."
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
    |i|
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
    (self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1493
	i := self asInteger.
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1494
	self = i ifTrue:[
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1495
	    ^ i hash
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1496
	].
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
    ].
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1499
    ^ self asFloat hash
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1502
     1.2345 hash
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1503
     1.2345 asLongFloat hash
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1504
     1 hash
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1505
     1.0 hash
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1506
     1.0 asLongFloat hash
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
    "
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1510
isAlmostEqualTo:aNumber nEpsilon:nE
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1511
    "return true, if the argument, aNumber represents almost the same numeric value
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1512
     as the receiver, false otherwise.
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1513
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1514
     nE is the number of minimal float distances, that the numbers may differ and
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1515
     still be considered equal.
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1516
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1517
     For background information why floats need this
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1518
     read: http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1519
    "
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1520
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1521
    Epsilon isNil ifTrue:[
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1522
	Epsilon := self class computeEpsilon.
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1523
    ].
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1524
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1525
%{  /* NOCONTEXT */
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1526
#ifdef INT128
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1527
    /*
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1528
     * notice:
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1529
     * the following inline code handles some common cases,
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1530
     * and exists as an optimization, to speed up those cases.
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1531
     *
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1532
     * Conceptionally, (and for most other argument types),
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1533
     * mixed arithmetic is implemented by double dispatching
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1534
     * (see the message send at the bottom)
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1535
     */
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1536
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1537
    INT128 ulpDiff;
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1538
    union {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1539
	LONGFLOAT_t f;
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1540
	INT128 i;
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1541
    } myself, otherFloat;
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1542
    int nEpsilon;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1543
    LONGFLOAT_t scaledEpsilon;
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1544
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1545
    if (!__isSmallInteger(nE)) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1546
	goto tryHarder;
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1547
    }
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1548
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1549
    nEpsilon =  __intVal(nE);
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1550
    scaledEpsilon = nEpsilon *__longFloatVal(@global(Epsilon));
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1551
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1552
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1553
	otherFloat.f = (LONGFLOAT_t)(__intVal(aNumber));
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1554
    } else if (aNumber == nil) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1555
	RETURN(false)
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1556
    } else if (__qIsLongFloat(aNumber)) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1557
	otherFloat.f = __longFloatVal(aNumber);
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1558
    } else if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1559
	otherFloat.f = (LONGFLOAT_t)(__floatVal(aNumber));
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1560
    } else if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1561
	otherFloat.f = (LONGFLOAT_t)(__shortFloatVal(aNumber));
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1562
    } else {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1563
	goto tryHarder;
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1564
    }
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1565
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1566
    myself.f = __longFloatVal(self);
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1567
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1568
    // Check if the numbers are really close -- needed
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1569
    // when comparing numbers near zero (ULP method below fails for numbers near 0!).
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1570
    if (fabsl(myself.f - otherFloat.f) <= scaledEpsilon) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1571
	RETURN(true);
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1572
    }
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1573
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1574
    // if the signs differ, the numbers are different
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1575
    if ((myself.f >= 0) != (otherFloat.f >= 0)) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1576
	RETURN(false);
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1577
    }
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1578
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1579
    // compute the difference of the 'units in the last place" ULP
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1580
    // (if ulpDiff == 1, two floats are adjecant)
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1581
    ulpDiff = myself.i - otherFloat.i;
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1582
    if (ulpDiff < 0) ulpDiff = -ulpDiff;
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1583
    if (ulpDiff <= nEpsilon) {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1584
	RETURN(true);
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1585
    } else {
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1586
	RETURN(false)
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1587
    }
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1588
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1589
tryHarder:;
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1590
#endif // INT128
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1591
%}.
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1592
    ^ super isAlmostEqualTo:aNumber nEpsilon:nE.
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1593
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1594
    "
24249
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1595
	67329.234q isAlmostEqualTo:67329.234q + self epsilon nEpsilon:1
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1596
	1.0 asLongFloat isAlmostEqualTo:1.0001 nEpsilon:1
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1597
	1.0 asLongFloat isAlmostEqualTo:-1.0 nEpsilon:1
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1598
	1.0 asLongFloat isAlmostEqualTo:1 nEpsilon:1
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1599
	0.0 asLongFloat isAlmostEqualTo:0 nEpsilon:1
17326e1df17f raise exception on out-of-range in asShortFloat / asFloat
Claus Gittinger <cg@exept.de>
parents: 24205
diff changeset
  1600
	0.0 asLongFloat isAlmostEqualTo:self epsilon nEpsilon:1
22855
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1601
    "
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1602
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1603
    "Created: / 09-05-2018 / 23:31:18 / stefan"
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1604
    "Modified: / 10-05-2018 / 01:03:24 / stefan"
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1605
!
84bb9781eee1 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22790
diff changeset
  1606
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1607
~= aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1608
    "return true, if the arguments value are not equal."
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
%{  /* NOCONTEXT */
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
    if (__isSmallInteger(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1613
	RETURN ( (__longFloatVal(self) != (LONGFLOAT_t)(__intVal(aNumber))) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
    }
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1615
    if (aNumber != nil) {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1616
	if (__isLongFloat(aNumber)) {
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1617
	    RETURN ( (__longFloatVal(self) != __longFloatVal(aNumber)) ? true : false );
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1618
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1619
	if (__qIsFloatLike(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1620
	    RETURN ( (__longFloatVal(self) != (LONGFLOAT_t)(__floatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1621
	}
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1622
	if (__qIsShortFloat(aNumber)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1623
	    RETURN ( (__longFloatVal(self) != (LONGFLOAT_t)(__shortFloatVal(aNumber))) ? true : false );
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1624
	}
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1625
    } else {
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1626
	RETURN ( true );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
    }
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
%}.
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1629
    ^ super ~= aNumber
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1630
! !
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1631
24190
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1632
!LongFloat methodsFor:'copying'!
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1633
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1634
deepCopy
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1635
    "return a deep copy of myself
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1636
     - because storing into floats is not recommended/allowed, its ok to return the receiver"
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1637
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1638
    ^ self
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1639
!
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1640
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1641
deepCopyUsing:aDictionary postCopySelector:postCopySelector
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1642
    "return a deep copy of myself
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1643
     - because storing into floats is not recommended/allowed, its ok to return the receiver"
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1644
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1645
    ^ self
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1646
!
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1647
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1648
shallowCopy
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1649
    "return a shallow copy of the receiver"
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1650
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1651
    ^ self
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1652
!
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1653
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1654
simpleDeepCopy
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1655
    "return a deep copy of the receiver
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1656
     - because storing into floats is not recommended/allowed, its ok to return the receiver"
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1657
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1658
    ^ self
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1659
! !
80408f7663d1 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24151
diff changeset
  1660
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1661
!LongFloat methodsFor:'double dispatching'!
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1662
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1663
productFromInteger:anInteger
24276
f748df283009 documentation
Claus Gittinger <cg@exept.de>
parents: 24275
diff changeset
  1664
    "sent when an integer does not know how to multiply the receiver, self"
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1665
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1666
%{  /* NOCONTEXT */
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1667
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1668
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1669
    LONGFLOAT_t result;
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1670
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1671
    if (__isSmallInteger(anInteger)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1672
	result = __longFloatVal(self) * (LONGFLOAT_t)(__intVal(anInteger));
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1673
retResult:
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1674
	__qMKLFLOAT(newFloat, result);
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1675
	RETURN ( newFloat );
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1676
    }
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1677
%}.
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1678
    ^ super productFromInteger:anInteger
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1679
!
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1680
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1681
sumFromInteger:anInteger
24276
f748df283009 documentation
Claus Gittinger <cg@exept.de>
parents: 24275
diff changeset
  1682
    "sent when an integer does not know how to add the receiver, self"
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1683
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1684
%{  /* NOCONTEXT */
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1685
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1686
    OBJ newFloat;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1687
    LONGFLOAT_t result;
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1688
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1689
    if (__isSmallInteger(anInteger)) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1690
	result = __longFloatVal(self) + (LONGFLOAT_t)(__intVal(anInteger));
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1691
retResult:
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1692
	__qMKLFLOAT(newFloat, result);
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1693
	RETURN ( newFloat );
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1694
    }
10319
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1695
%}.
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1696
    ^ super sumFromInteger:anInteger
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1697
! !
d89f3a159d73 double dispatching
Claus Gittinger <cg@exept.de>
parents: 10314
diff changeset
  1698
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1699
!LongFloat methodsFor:'mathematical functions'!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1700
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1701
exp
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1702
    "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
  1703
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1704
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1705
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1706
%{
7374
f3bc94a9a373 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7372
diff changeset
  1707
#if defined(LONG_exp)
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1708
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1709
    LONGFLOAT_t rslt;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1710
    OBJ newFloat;
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1711
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1712
    __threadErrno = 0;
7374
f3bc94a9a373 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7372
diff changeset
  1713
    rslt = LONG_exp(__longFloatVal(self));
7383
0219aa6bd824 hyperbolic functions
Claus Gittinger <cg@exept.de>
parents: 7382
diff changeset
  1714
# ifdef LONG_isnan
0219aa6bd824 hyperbolic functions
Claus Gittinger <cg@exept.de>
parents: 7382
diff changeset
  1715
    if (! LONG_isnan(rslt))
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1716
# endif
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1717
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1718
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1719
	RETURN ( newFloat );
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1720
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1721
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1722
    useFallBack = true;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1723
#endif
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1724
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1725
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1726
	^ super exp
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1727
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1728
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1729
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1730
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1731
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1732
	selector:#exp
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1733
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1734
	errorString:'bad receiver in exp'
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1735
!
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1737
ln
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1738
    "return the natural logarithm of myself.
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1739
     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
  1740
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1741
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1742
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1743
%{
7374
f3bc94a9a373 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7372
diff changeset
  1744
#if defined(LONG_log)
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1745
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1746
    LONGFLOAT_t val, rslt;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1747
    OBJ newFloat;
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1748
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1749
    val = __longFloatVal(self);
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1750
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1751
    /*
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1752
     * to suppress the warnBox opened by win32
21951
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  1753
     * to avoid returning -INF from some unix math libs (__osx__)
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  1754
     */
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  1755
    if (val > 0.0) {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1756
	__threadErrno = 0;
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1757
	rslt = LONG_log(val);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1758
# ifdef LONG_isnan
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1759
	if (! LONG_isnan(rslt))
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1760
# endif
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1761
	{
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1762
	    if (__threadErrno == 0) {
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1763
		__qMKLFLOAT(newFloat, rslt);
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1764
		RETURN ( newFloat );
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1765
	    }
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1766
	}
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1767
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1768
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1769
    useFallBack = true;
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1770
#endif
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1771
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1772
    useFallBack notNil ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1773
	^ super ln
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1774
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1775
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1776
    "
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1777
     an invalid value for logarithm
21971
9e7d9bb12714 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21969
diff changeset
  1778
     if you need -INF for a zero receiver, try Number trapInfinity:[...]
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1779
    "
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1780
    ^ self class
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1781
	raise:(self = 0 ifTrue:[#infiniteResultSignal] ifFalse:[#domainErrorSignal])
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1782
	receiver:self
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1783
	selector:#ln
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1784
	arguments:#()
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1785
	errorString:'bad receiver in ln (not strictly positive)'
21951
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  1786
21971
9e7d9bb12714 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21969
diff changeset
  1787
    "Modified (comment): / 03-07-2017 / 15:57:57 / cg"
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1788
!
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1789
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1790
log10
21826
feedd7dc695d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20706
diff changeset
  1791
    "return the base-10 logarithm of the receiver.
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1792
     Raises an exception, if the receiver is less or equal to zero."
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1793
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1794
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1795
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1796
%{
7374
f3bc94a9a373 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7372
diff changeset
  1797
#if defined(LONG_log10)
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1798
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1799
    LONGFLOAT_t val, rslt;
7372
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1800
    OBJ newFloat;
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1801
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1802
    val = __longFloatVal(self);
e31df0bf0c05 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7357
diff changeset
  1803
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1804
    /*
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1805
     * to suppress the warnBox opened by win32
21954
22f39512bde3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21951
diff changeset
  1806
     * to avoid returning -INF from some unix math libs (__osx__)
22f39512bde3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21951
diff changeset
  1807
     */
22f39512bde3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21951
diff changeset
  1808
    if (val > 0.0) {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1809
	__threadErrno = 0;
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1810
	rslt = LONG_log10(val);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1811
# ifdef LONG_isnan
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1812
	if (! LONG_isnan(rslt))
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1813
# endif
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1814
	{
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1815
	    if (__threadErrno == 0) {
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1816
		__qMKLFLOAT(newFloat, rslt);
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1817
		RETURN ( newFloat );
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1818
	    }
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1819
	}
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1820
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1821
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1822
    useFallBack = true;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1823
#endif
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1824
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1825
    useFallBack notNil ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1826
	^ super log10
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1827
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1828
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1829
    "
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1830
     an invalid value for logarithm
21971
9e7d9bb12714 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21969
diff changeset
  1831
     if you need -INF for a zero receiver, try Number trapInfinity:[...]
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1832
    "
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1833
    ^ self class
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1834
	raise:(self = 0 ifTrue:[#infiniteResultSignal] ifFalse:[#domainErrorSignal])
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1835
	receiver:self
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1836
	selector:#log10
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1837
	arguments:#()
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1838
	errorString:'bad receiver in log10 (not strictly positive)'
21954
22f39512bde3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21951
diff changeset
  1839
21971
9e7d9bb12714 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21969
diff changeset
  1840
    "Modified (comment): / 03-07-2017 / 15:58:06 / cg"
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1841
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1842
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1843
raisedTo:aNumber
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1844
    "return self raised to the power of aNumber"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1845
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1846
    |n useFallBack|
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1847
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1848
    n := aNumber asFloat.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1849
%{
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1850
#if defined(LONG_pow)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1851
    LONGFLOAT_t rslt;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1852
    OBJ newFloat;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1853
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1854
    if (__isFloatLike(n)) {
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1855
	__threadErrno = 0;
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1856
	rslt = LONG_pow(__longFloatVal(self), __floatVal(n));
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1857
# ifdef LONG_isnan
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1858
	if (! LONG_isnan(rslt))
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1859
# endif
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1860
	{
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1861
	    if (__threadErrno == 0) {
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1862
		__qMKLFLOAT(newFloat, rslt);
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1863
		RETURN ( newFloat );
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1864
	    }
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1865
	}
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1866
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1867
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1868
    useFallBack = true;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1869
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1870
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1871
    useFallBack notNil ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1872
	^ super raisedTo:aNumber
19090
c044866c92eb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18853
diff changeset
  1873
    ].
c044866c92eb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18853
diff changeset
  1874
21914
d607355aa373 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21907
diff changeset
  1875
    "/ the c-library pow function, has a bug:
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  1876
    "/ it does not deal correctly with negative numbers.
19090
c044866c92eb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18853
diff changeset
  1877
    "/ I.e. it raises an error on -8^(1/3) instead of returning a negative -2
c044866c92eb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18853
diff changeset
  1878
    "/ work around with a kludge:
c044866c92eb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18853
diff changeset
  1879
    self < 0 ifTrue:[
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1880
	^ (self negated raisedTo:n) negated
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1881
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1882
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1883
    "
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1884
     an invalid argument (not convertable to float ?)
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1885
    "
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1886
    ^ self class
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1887
	raise:#domainErrorSignal
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1888
	receiver:self
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1889
	selector:#raisedTo:
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1890
	arguments:(Array with:aNumber)
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  1891
	errorString:'bad receiver/arg in raisedTo:'
21914
d607355aa373 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21907
diff changeset
  1892
d607355aa373 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21907
diff changeset
  1893
    "Modified: / 22-06-2017 / 15:54:59 / cg"
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1894
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1895
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1896
sqrt
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1897
    "return the square root of myself.
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1898
     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
  1899
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1900
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1901
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  1902
%{
7374
f3bc94a9a373 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7372
diff changeset
  1903
#if defined(LONG_sqrt)
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1904
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  1905
    LONGFLOAT_t val, rslt;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1906
    OBJ newFloat;
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1907
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1908
    val = __longFloatVal(self);
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1909
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  1910
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1911
    if (val >= 0.0)
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1912
# endif
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1913
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1914
	__threadErrno = 0;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1915
	rslt = LONG_sqrt(val);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1916
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1917
	if (! LONG_isnan(rslt))
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1918
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1919
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1920
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1921
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1922
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1923
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1924
	}
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1925
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1926
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  1927
    useFallBack = true;
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1928
#endif
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1929
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1930
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1931
	^ super sqrt
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1932
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  1933
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1934
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1935
	raise:#imaginaryResultSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1936
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1937
	selector:#sqrt
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1938
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  1939
	errorString:'bad (negative) receiver in sqrt'
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1940
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1941
    "
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1942
     10 asLongFloat sqrt
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1943
     -10 asLongFloat sqrt
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1944
    "
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1945
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  1946
    "Modified: / 16.11.2001 / 14:14:43 / cg"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1947
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1948
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1949
!LongFloat methodsFor:'printing & storing'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
22300
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1951
printOn:aStream
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1952
    "append a printed representation of the receiver to
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1953
     the argument, aStream.
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1954
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1955
     I use #printString instead of #printOn: as basic print mechanism."
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1956
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1957
    aStream nextPutAll:self printString
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1958
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1959
    "Created: / 10-10-2017 / 14:05:22 / cg"
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1960
!
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  1961
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1962
printString
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1963
    "return a printed representation of the receiver
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1964
     LimitedPrecisonReal and its subclasses use #printString instead of
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1965
     #printOn: as basic print mechanism."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1966
18137
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1967
    ^ self printStringWithFormat:DefaultPrintFormat
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1968
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1969
    "
24818
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1970
     LongFloat pi printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1971
     1.234 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1972
     1.0 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1973
     1e10 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1974
     1.2e3 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1975
     1.2e30 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1976
     (1.0 uncheckedDivide:0) asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1977
     (0.0 uncheckedDivide:0) asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1978
     self pi printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1979
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1980
     DecimalPointCharacterForPrinting := $,.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1981
     1.234 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1982
     1.0 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1983
     1e10 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1984
     1.2e3 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1985
     1.2e30 asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1986
     (1.0 uncheckedDivide:0) asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1987
     (0.0 uncheckedDivide:0) asLongFloat printString.
fb24167bfb3d #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24704
diff changeset
  1988
     DecimalPointCharacterForPrinting := $.
18137
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1989
    "
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1990
!
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1991
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1992
printStringWithFormat:format
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1993
    "return a printed representation of the receiver;
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1994
     fmt must be of the form: .nn, where nn is the number of digits.
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1995
     To print 6 valid digits, use printStringWithFormat:'.6'
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1996
     For Floats, the default used in printString, is 15 (because its a double);
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1997
     for ShortFloats, it is 6 (because it is a float)"
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  1998
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  1999
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2000
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2001
    char buffer[64];
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2002
    char fmtBuffer[20];
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2003
    char *fmt;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2004
    REGISTER char *cp;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2005
    OBJ s;
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2006
    int len ;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2007
18137
ee16eb999143 class: LongFloat
Claus Gittinger <cg@exept.de>
parents: 18132
diff changeset
  2008
    if (__isStringLike(format)) {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2009
	fmt = (char *) __stringVal(format);
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2010
    } else {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2011
	fmt = ".19";
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2012
    }
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2013
    /*
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2014
     * build a printf format string
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2015
     */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2016
    fmtBuffer[0] = '%';
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2017
    strncpy(fmtBuffer+1, fmt, 10);
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2018
    if (sizeof(LONGFLOAT_t) == sizeof(double)) {
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2019
#ifdef SYSV
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2020
	strcat(fmtBuffer, "lg");
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2021
#else
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2022
	strcat(fmtBuffer, "G");
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2023
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2024
    } else {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2025
	strcat(fmtBuffer, "LG");
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2026
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2027
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2028
    /*
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2029
     * 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
  2030
     * 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
  2031
     * 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
  2032
     */
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2033
    __BEGIN_PROTECT_REGISTERS__
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2034
    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
  2035
    __END_PROTECT_REGISTERS__
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2036
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2037
    if (len >= 0 && len < sizeof(buffer)-3) {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2038
	/*
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2039
	 * kludge to make integral float f prints as "f.0" (not as "f" as printf does)
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2040
	 * (i.e. look if string contains '.' or 'e' and append '.0' if not)
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2041
	 */
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2042
	for (cp = buffer; *cp; cp++) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2043
	    if ((*cp == '.') || (*cp == ',') || (*cp == 'E') || (*cp == 'e')) break;
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2044
	}
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2045
	if (!*cp && (cp[-1] >= '0') && (cp[-1] <= '9')) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2046
	    if (__isCharacter(@global(DecimalPointCharacterForPrinting))) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2047
		*cp++ = __intVal(__characterVal(@global(DecimalPointCharacterForPrinting)));
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2048
	    } else {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2049
		*cp++ = '.';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2050
	    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2051
	    *cp++ = '0';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2052
	    *cp = '\0';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2053
	} else {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2054
	    if (cp && (*cp == '.')) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2055
		if (__isCharacter(@global(DecimalPointCharacterForPrinting))) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2056
		    *cp = __intVal(__characterVal(@global(DecimalPointCharacterForPrinting)));
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2057
		}
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2058
	    }
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2059
	}
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2060
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2061
	s = __MKSTRING(buffer);
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2062
	if (s != nil) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2063
	    RETURN (s);
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2064
	}
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2065
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2066
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2067
    "
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2068
     memory allocation (for the new string) failed.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2069
     When we arrive here, there was no memory, even after a garbage collect.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2070
     This means, that the VM wanted to get some more memory from the
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2071
     OS, which was not kind enough to give it.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2072
     Bad luck - you should increase the swap space on your machine.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2073
    "
20706
009b8269bd08 we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents: 20419
diff changeset
  2074
    ^ AllocationFailure raise.
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2075
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2076
    "
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2077
	1.234 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2078
	1.0 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2079
	1e10 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2080
	1.2e3 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2081
	1.2e30 asLongFloat printString.
19329
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  2082
	(1.0 uncheckedDivide:0)  isInfinite.
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  2083
	(0.0 uncheckedDivide:0)  isNaN.
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  2084
	(1.0 uncheckedDivide:0) asLongFloat isInfinite.
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  2085
	(0.0 uncheckedDivide:0) asLongFloat isNaN.
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2086
	(1.0 uncheckedDivide:0) asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2087
	(0.0 uncheckedDivide:0) asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2088
	self pi printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2089
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2090
	DecimalPointCharacterForPrinting := $,.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2091
	1.234 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2092
	1.0 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2093
	1e10 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2094
	1.2e3 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2095
	1.2e30 asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2096
	(1.0 uncheckedDivide:0) asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2097
	(0.0 uncheckedDivide:0) asLongFloat printString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2098
	DecimalPointCharacterForPrinting := $.
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2099
    "
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  2100
!
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2101
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2102
printfPrintString:formatString
24691
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2103
    <unsave>
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2104
7746
4a4208ef7699 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7731
diff changeset
  2105
    "non-standard: return a printed representation of the receiver
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2106
     as specified by formatString, which is defined by printf.
21951
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  2107
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2108
     If you use this, be aware, that specifying long doubles differs on
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2109
     systems; on Linux/gnuc machines you have to give something like %LF/%LG.
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2110
     Also, the resulting string may not be longer than 255 bytes -
20419
a37b99ec87a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
  2111
     since that's the (static) size of the buffer.
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  2112
11925
6c93ef7cb9ff changed #printfPrintString:
Claus Gittinger <cg@exept.de>
parents: 11729
diff changeset
  2113
     This method is NONSTANDARD and may be removed without notice.
24691
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2114
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2115
     WARNING: this goes directly to the C-printf function and may therefore me inherently unsafe.
11925
6c93ef7cb9ff changed #printfPrintString:
Claus Gittinger <cg@exept.de>
parents: 11729
diff changeset
  2116
     Please use the printf: method, which is safe as it is completely implemented in Smalltalk."
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2117
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2118
%{  /* STACK: 16000 */
24691
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2119
#ifndef __SCHTEAM__
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2120
    char buffer[1024];
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2121
    OBJ s;
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2122
    int len;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2123
12476
66b5104cedc9 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 11925
diff changeset
  2124
    if (__isStringLike(formatString)) {
25036
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2125
	/*
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2126
	 * actually only needed on sparc: since thisContext is
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2127
	 * in a global register, which gets destroyed by printf,
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2128
	 * manually save it here - very stupid ...
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2129
	 */
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2130
	__BEGIN_PROTECT_REGISTERS__
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2131
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2132
	len = snprintf(buffer, sizeof(buffer), __stringVal(formatString), __longFloatVal(self));
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2133
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2134
	__END_PROTECT_REGISTERS__
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2135
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2136
	if (len < 0) goto fail;
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2137
	if (len >= sizeof(buffer)) goto fail;
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2138
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2139
	s = __MKSTRING_L(buffer, len);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2140
	if (s != nil) {
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2141
	    RETURN (s);
a92213ab83ac borland fix
Claus Gittinger <cg@exept.de>
parents: 25027
diff changeset
  2142
	}
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2143
    }
8417
dcba76518224 Security: use snprintf() instead of sprintf() to avoid overwrites.
Stefan Vogel <sv@exept.de>
parents: 7831
diff changeset
  2144
fail: ;
24691
df00d245c465 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24470
diff changeset
  2145
#endif /* not __SCHTEAM__ */
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2146
%}.
21907
d0143f6eef88 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 21889
diff changeset
  2147
    ^ super printfPrintString:formatString
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2148
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2149
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2150
     Float pi asLongFloat printfPrintString:'%%LG -> %LG'
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2151
     Float pi asLongFloat printfPrintString:'%%LF -> %LF'
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2152
     Float pi asLongFloat printfPrintString:'%%7.15LG -> %7.15LG'
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2153
     Float pi asLongFloat printfPrintString:'%%7.15LF -> %7.15LF'
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2154
    "
21907
d0143f6eef88 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 21889
diff changeset
  2155
21951
067f8ab0f3f5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21914
diff changeset
  2156
    "Modified (comment): / 03-07-2017 / 15:11:48 / cg"
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2157
!
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2158
22300
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2159
storeOn:aStream
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2160
    "append a printed representation of the receiver to
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2161
     the argument, aStream.
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2162
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2163
     I use #storeString instead of #storeOn: as basic store mechanism."
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2164
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2165
    aStream nextPutAll:self storeString
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2166
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2167
    "Created: / 10-10-2017 / 14:06:46 / cg"
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2168
!
8ba20eef917f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22258
diff changeset
  2169
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2170
storeString
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2171
    "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
  2172
     all valid digits are printed.
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2173
     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
  2174
     #storeOn: as basic print mechanism."
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2175
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2176
%{  /* NOCONTEXT */
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2177
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2178
    char buffer[64];
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2179
    REGISTER char *cp;
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2180
    OBJ s;
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2181
    int len;
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2182
    char *fmtBuffer;
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2183
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2184
    /*
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2185
     * build a printf format string
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2186
     */
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2187
    if (sizeof(LONGFLOAT_t) == sizeof(double)) {
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  2188
#ifdef SYSV
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2189
	fmtBuffer = "%.17lg";
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  2190
#else
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2191
	fmtBuffer = "%.17G";
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  2192
#endif
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  2193
    } else {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2194
	fmtBuffer = "%.20LG";
14673
d3c91be01e96 setlocale only once and for all in stxmain
Claus Gittinger <cg@exept.de>
parents: 14600
diff changeset
  2195
    }
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2196
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2197
    __BEGIN_PROTECT_REGISTERS__
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2198
    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
  2199
    __END_PROTECT_REGISTERS__
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2200
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2201
    if (len >= 0 && len < sizeof(buffer)-3) {
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2202
	/*
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2203
	 * kludge to make integral float f prints as "f.0" (not as "f" as printf does)
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2204
	 * (i.e. look if string contains '.' or 'e' and append '.0' if not)
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2205
	 */
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2206
	for (cp = buffer; *cp; cp++) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2207
	    if ((*cp == '.') || (*cp == ',') || (*cp == 'E') || (*cp == 'e')) break;
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2208
	}
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2209
	if (!*cp && (cp[-1] >= '0') && (cp[-1] <= '9')) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2210
	    *cp++ = '.';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2211
	    *cp++ = '0';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2212
	    *cp = '\0';
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2213
	}
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2214
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2215
	s = __MKSTRING(buffer);
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2216
	if (s != nil) {
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2217
	    RETURN (s);
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2218
	}
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2219
    }
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2220
%}.
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2221
    "
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2222
     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
  2223
     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
  2224
     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
  2225
     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
  2226
     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
  2227
    "
20706
009b8269bd08 we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents: 20419
diff changeset
  2228
    ^ AllocationFailure raise.
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2229
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2230
    "
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2231
	1.0 asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2232
	1.234 asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2233
	1e10 asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2234
	1.2e3 asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2235
	1.2e30 asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2236
	LongFloat pi asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2237
	(1.0 uncheckedDivide:0) asLongFloat storeString
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2238
	(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
  2239
9122
858a4118a135 comment; decimalPoint classVars renamed
Claus Gittinger <cg@exept.de>
parents: 8984
diff changeset
  2240
     notice that the storeString is NOT affected by DecimalPointCharacterForPrinting:
858a4118a135 comment; decimalPoint classVars renamed
Claus Gittinger <cg@exept.de>
parents: 8984
diff changeset
  2241
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2242
	DecimalPointCharacterForPrinting := $,.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2243
	1.234 asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2244
	1.0 asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2245
	1e10 asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2246
	1.2e3 asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2247
	1.2e30 asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2248
	(1.0 uncheckedDivide:0) asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2249
	(0.0 uncheckedDivide:0) asLongFloat storeString.
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2250
	DecimalPointCharacterForPrinting := $.
8422
c206b4711b6e Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents: 8417
diff changeset
  2251
    "
5885
91ff479e693b added #defaultNumberOfDigits
Claus Gittinger <cg@exept.de>
parents: 5822
diff changeset
  2252
! !
91ff479e693b added #defaultNumberOfDigits
Claus Gittinger <cg@exept.de>
parents: 5822
diff changeset
  2253
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2254
!LongFloat methodsFor:'private-accessing'!
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2255
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2256
basicAt:index
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2257
    "return an internal byte of the float.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2258
     The value returned here depends on byte order, float representation etc.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2259
     Therefore, this method should be used strictly private.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2260
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2261
     Notice:
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2262
	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
  2263
	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
  2264
	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
  2265
	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
  2266
	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
  2267
	values as if this filler wasnt present."
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2268
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2269
%{  /* NOCONTEXT */
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2270
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2271
    register int indx;
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2272
    unsigned char *cp;
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2273
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2274
    /*
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2275
     * notice the missing test for self being a nonNilObject -
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2276
     * this can be done since basicAt: is defined both in UndefinedObject
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2277
     * and SmallInteger
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2278
     */
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2279
    if (__isSmallInteger(index)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2280
	indx = __intVal(index) - 1;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2281
	if (((unsigned)(indx)) < sizeof(LONGFLOAT_t)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2282
	    cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8706
diff changeset
  2283
	    RETURN ( __mkSmallInteger(cp[indx] & 0xFF) );
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2284
	}
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2285
    }
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2286
%}.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2287
    ^ self indexNotIntegerOrOutOfBounds:index
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2288
!
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2289
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2290
basicAt:index put:value
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2291
    "set an internal byte of the float.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2292
     The value to be stored here depends on byte order, float representation etc.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2293
     Therefore, this method should be used strictly private.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2294
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2295
     Notice:
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2296
	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
  2297
	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
  2298
	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
  2299
	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
  2300
	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
  2301
	values as if this filler wasnt present."
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2302
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2303
%{  /* NOCONTEXT */
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2304
    register int indx, val;
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2305
    unsigned char *cp;
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2306
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2307
    /*
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2308
     * notice the missing test for self being a nonNilObject -
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2309
     * this can be done since basicAt: is defined both in UndefinedObject
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2310
     * and SmallInteger
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2311
     */
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2312
    if (__bothSmallInteger(index, value)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2313
	val = __intVal(value);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2314
	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
  2315
	    indx = __intVal(index) - 1;
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2316
	    if (((unsigned)(indx)) < sizeof(LONGFLOAT_t)) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2317
		cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2318
		cp[indx] = val;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2319
		RETURN ( value );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2320
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2321
	}
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2322
    }
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2323
%}.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2324
    value isInteger ifFalse:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2325
	"
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2326
	 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
  2327
	"
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2328
	^ self elementNotInteger
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2329
    ].
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2330
    (value between:0 and:255) ifFalse:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2331
	"
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2332
	 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
  2333
	"
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2334
	^ self elementBoundsError:value
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2335
    ].
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2336
    ^ self indexNotIntegerOrOutOfBounds:index
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2337
!
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2338
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2339
basicSize
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2340
    "return the size in bytes of the float.
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2341
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2342
     Notice:
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2343
	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
  2344
	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
  2345
	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
  2346
	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
  2347
	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
  2348
	values as if this filler wasnt present."
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2349
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2350
%{  /* NOCONTEXT */
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2351
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2352
    RETURN (__mkSmallInteger(sizeof(LONGFLOAT_t)));
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2353
%}.
22258
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2354
!
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2355
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2356
byteAt:index
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2357
    ^ self basicAt:index
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2358
!
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2359
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2360
byteAt:index put:newByte
4f711d284370 #BUGFIX by sr
sr
parents: 22100
diff changeset
  2361
    self shouldNotImplement
7415
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2362
! !
eac306452d5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7414
diff changeset
  2363
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
!LongFloat methodsFor:'special access'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2366
exponent
24965
9de698b84956 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24952
diff changeset
  2367
    "extract a normalized float's (unbiased) exponent.
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2368
     The returned value depends on the float-representation of
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2369
     the underlying machine and is therefore highly unportable.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2370
     This is not for general use.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2371
     This assumes that the mantissa is normalized to
21851
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2372
     0.5 .. 1.0 and the float's value is mantissa * 2^exp"
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2373
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2374
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2375
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2376
#if defined(LONG_frexp)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8706
diff changeset
  2377
    int exp;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2378
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2379
    LONG_frexp( __longFloatVal(self), &exp);
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2380
    RETURN (__mkSmallInteger(exp));
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2381
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2382
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2383
    ^ super exponent
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2384
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2385
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2386
     4.0q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2387
     2.0q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2388
     1.0q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2389
     0.5q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2390
     0.25q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2391
     0.00000011111q exponent
21851
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2392
     1.0q1000 exponent
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2393
    "
21851
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2394
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2395
    "Modified (comment): / 20-06-2017 / 11:20:40 / cg"
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2396
!
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2397
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2398
mantissa
24151
9105660f5693 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22855
diff changeset
  2399
    "extract a normalized float's mantissa.
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2400
     The returned value depends on the float-representation of
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2401
     the underlying machine and is therefore highly unportable.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2402
     This is not for general use.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2403
     This assumes that the mantissa is normalized to
24151
9105660f5693 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22855
diff changeset
  2404
     0.5 .. 1.0 and the float's value is mantissa * 2^exp"
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2405
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2406
%{  /* NOCONTEXT */
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2407
#if defined(LONG_frexp)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2408
    LONGFLOAT_t frac;
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2409
    int exp;
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2410
    OBJ v;
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2411
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2412
    frac = LONG_frexp( __longFloatVal(self), &exp);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2413
    __qMKLFLOAT(v, frac);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2414
    RETURN (v);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2415
#endif
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2416
%}.
21851
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2417
    ^ super mantissa
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2418
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2419
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2420
     1.0q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2421
     1.0q asLongFloat mantissa
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2422
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2423
     0.5q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2424
     0.5q  mantissa
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2425
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2426
     0.25q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2427
     0.25q mantissa
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2428
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2429
     0.00000011111q exponent
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  2430
     0.00000011111q mantissa
25013
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2431
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2432
     self assert:(1.0 asLongFloat mantissa * (2 raisedTo:1.0 asLongFloat exponent)) = 1.0 asLongFloat.
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2433
     self assert:(100.0 asLongFloat mantissa * (2 raisedTo:100.0 asLongFloat exponent)) = 100.0 asLongFloat.
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2434
     self assert:(10e15 asLongFloat mantissa * (2 raisedTo:10e15 asLongFloat exponent)) = 10e15 asLongFloat.
eb9cf7e9d6b5 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24989
diff changeset
  2435
     self assert:(10e-15 asLongFloat mantissa * (2 raisedTo:10e-15 asLongFloat exponent)) = 10e-15 asLongFloat.
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  2436
    "
21851
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2437
64aecf11c224 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21826
diff changeset
  2438
    "Modified: / 20-06-2017 / 11:33:24 / cg"
24151
9105660f5693 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22855
diff changeset
  2439
    "Modified (comment): / 26-05-2019 / 03:13:08 / Claus Gittinger"
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2442
!LongFloat methodsFor:'testing'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2444
isFinite
24704
807430cfebdb #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24691
diff changeset
  2445
    "return true, if the receiver is a finite float (not NaN and not +/-INF)"
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2446
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2447
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2448
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2449
#ifdef LONG_finite
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2450
    LONGFLOAT_t lV = __longFloatVal(self);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2451
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2452
    if (LONG_finite(lV)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2453
	RETURN (true);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2454
    } else {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2455
	RETURN (false);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2456
    }
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2457
#else
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2458
    double dV = (double) __longFloatVal(self);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2459
8980
abee9fcb0385 cleanup isfinite() and isnan() - usage (HPUX)
Stefan Vogel <sv@exept.de>
parents: 8913
diff changeset
  2460
    if (isfinite(dV)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2461
	RETURN (true);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2462
    } else {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2463
	RETURN (false);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2464
    }
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2465
#endif
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2466
%}
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2467
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2468
    "
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2469
	1.0 asLongFloat isFinite
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2470
	(0.0 asLongFloat uncheckedDivide: 0.0) isFinite
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2471
	(1.0 asLongFloat uncheckedDivide: 0.0) isFinite
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2472
	(-1.0 asLongFloat uncheckedDivide: 0.0) isFinite
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2473
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2476
isInfinite
24704
807430cfebdb #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24691
diff changeset
  2477
    "return true, if the receiver is an infinite float (+Inf or -Inf).
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2478
     These are not created by ST/X float operations (they raise an exception);
24704
807430cfebdb #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24691
diff changeset
  2479
     however, inline C-code could produce them."
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2480
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2481
%{  /* NOCONTEXT */
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2482
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2483
#ifdef LONG_infinite
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2484
    LONGFLOAT_t lV = __longFloatVal(self);
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2485
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2486
    if (LONG_infinite(lV)) { RETURN (true); }
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2487
    RETURN (false);
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2488
#else
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2489
# if defined(LONG_finite) && defined(LONG_isnan)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2490
    LONGFLOAT_t lV = __longFloatVal(self);
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2491
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2492
    if (!LONG_finite(lV) && !LONG_isnan(lV) ) { RETURN (true); }
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2493
    RETURN (false);
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2494
# endif
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2495
#endif
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2496
%}.
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2497
    ^ self isFinite not and:[self isNaN not]
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2498
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2499
    "
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2500
	1.0 asLongFloat isFinite -> true
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2501
	1.0 asLongFloat isInfinite -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2502
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2503
	(0.0 asLongFloat uncheckedDivide: 0.0) isFinite -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2504
	(0.0 asLongFloat uncheckedDivide: 0.0) isInfinite -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2505
	(0.0 asLongFloat uncheckedDivide: 0.0) isNaN -> true
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2506
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2507
	(1.0 asLongFloat uncheckedDivide: 0.0) isFinite -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2508
	(1.0 asLongFloat uncheckedDivide: 0.0) isInfinite -> true
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2509
	(1.0 asLongFloat uncheckedDivide: 0.0) isNaN -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2510
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2511
	(-1.0 asLongFloat uncheckedDivide: 0.0) isFinite -> false
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2512
	(-1.0 asLongFloat uncheckedDivide: 0.0) isInfinite -> true
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2513
	(-1.0 asLongFloat uncheckedDivide: 0.0) isNaN -> false
22100
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2514
    "
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2515
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2516
    "Created: / 25-07-2017 / 17:04:04 / cg"
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2517
!
c9b9cf3e0527 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21973
diff changeset
  2518
24946
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2519
isLongFloat
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2520
    "return true, if the receiver is some kind of long floating point number (iee extended precision)"
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2521
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2522
    ^ true
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2523
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2524
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2525
!
3f0576d4b793 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24932
diff changeset
  2526
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2527
isNaN
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2528
    "return true, if the receiver is an invalid float (NaN - not a number).
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2529
     These are not created by ST/X float operations (they raise an exception);
24704
807430cfebdb #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24691
diff changeset
  2530
     however, inline C-code could produce them."
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2531
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2532
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2533
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2534
#ifdef LONG_isnan
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2535
    LONGFLOAT_t lV = __longFloatVal(self);
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2536
    if (LONG_isnan(lV)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2537
	RETURN (true);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2538
    } else {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2539
	RETURN (false);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2540
    }
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2541
#else
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2542
    double dV = (double)(__longFloatVal(self));
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2543
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2544
    if (isnan(dV)) {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2545
	RETURN (true);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2546
    } else {
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2547
	RETURN (false);
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2548
    }
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2549
#endif
7396
e6bda581f000 isNan & isFinite for sparc
Claus Gittinger <cg@exept.de>
parents: 7395
diff changeset
  2550
%}
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2551
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2552
    "
24948
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2553
	1.0 asLongFloat isNaN
28079fece2a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24946
diff changeset
  2554
	(0.0 asLongFloat uncheckedDivide: 0.0) isNaN
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2555
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2556
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2558
isNegativeZero
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2559
    "many systems have two float.Pnt zeros"
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2560
17395
82852eb0d440 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17393
diff changeset
  2561
%{ /* NOCONTEXT */
17393
2c963130e1da class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17390
diff changeset
  2562
#if defined(__BORLANDC__)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2563
    union { LONGFLOAT_t ld; int i[3]; } __u;
17393
2c963130e1da class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17390
diff changeset
  2564
   __u.ld = __longFloatVal(self);
2c963130e1da class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17390
diff changeset
  2565
    RETURN ( (__u.ld == 0.0 && (__u.i[2] & 0x8000)) ? true : false );
17390
7fa2a6b7869f class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17381
diff changeset
  2566
#else
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2567
    RETURN ( (__longFloatVal(self) == 0.0 && signbit(__longFloatVal(self)) != 0) ? true : false );
17390
7fa2a6b7869f class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17381
diff changeset
  2568
#endif
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2569
%}.
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2570
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2571
    "
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2572
     0.0 asLongFloat isNegativeZero
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2573
     -0.0 asLongFloat isNegativeZero
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2574
    "
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2575
!
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2576
24329
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2577
isZero
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2578
    "return true, if the receiver is zero"
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2579
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2580
    ^ self = 0.0
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2581
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2582
    "Created: / 10-06-2019 / 22:00:23 / Claus Gittinger"
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2583
!
a430bb32eed2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24325
diff changeset
  2584
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2585
negative
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2586
    "return true if the receiver is less than zero.
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2587
     -0.0 is positive for now."
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2589
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2590
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2591
    RETURN ( __longFloatVal(self) < 0.0  ? true : false );
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2592
    // RETURN ( signbit(__longFloatVal(self)) != 0  ? true : false );
5411
c396c6640868 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  2593
%}.
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2594
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2595
    "
18363
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2596
	0.0 asLongFloat negative
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2597
	-0.0 asLongFloat negative
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2598
	1.0 asLongFloat negative
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2599
	-1.0 asLongFloat negative
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2600
	(1.0 uncheckedDivide: 0.0) asLongFloat negative
ec65c9912329 comments only
Claus Gittinger <cg@exept.de>
parents: 18137
diff changeset
  2601
	(-1.0 uncheckedDivide: 0.0) asLongFloat negative
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2602
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2605
numberOfBits
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2606
    "return the size (in bits) of the real;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2607
     typically, 80 or 96 is returned here,
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2608
     but who knows ..."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2609
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2610
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2611
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2612
    RETURN (__mkSmallInteger (sizeof(LONGFLOAT_t) * 8));
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2613
%}
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2614
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2615
    "
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2616
     LongFloat basicNew numberOfBits
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2617
     1.2 asLongFloat numberOfBits
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2618
     1.2 asShortFloat numberOfBits
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2619
     1.2 numberOfBits
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2620
    "
5357
39860dd8b0f5 query for number of bits
ps
parents: 5317
diff changeset
  2621
!
39860dd8b0f5 query for number of bits
ps
parents: 5317
diff changeset
  2622
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2623
positive
18853
60f1dbecace6 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18842
diff changeset
  2624
    "return true if the receiver is greater or equal to zero (not negative)
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2625
     0.0 and -0.0 are positive for now."
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2626
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2627
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2628
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2629
    RETURN ( __longFloatVal(self) >= 0.0 ? true : false );
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2630
//    RETURN ( (signbit(__longFloatVal(self)) == 0 ? true : false ) );
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2631
%}.
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2632
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2633
    "
19266
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2634
	0.0 asLongFloat positive
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2635
	-0.0 asLongFloat positive
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2636
	1.0 asLongFloat positive
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2637
	-1.0 asLongFloat positive
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2638
	(1.0 uncheckedDivide: 0.0) asLongFloat positive
b88783bebd62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 19090
diff changeset
  2639
	(-1.0 uncheckedDivide: 0.0) asLongFloat positive
17381
0dc059600e6e class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 17219
diff changeset
  2640
    "
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2641
!
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2642
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2643
strictlyPositive
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2644
    "return true if the receiver is greater than zero"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2645
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2646
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2647
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  2648
    RETURN ( (__longFloatVal(self) > 0.0) ? true : false );
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
%}
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2652
!LongFloat methodsFor:'trigonometric'!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2653
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2654
arcCos
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2655
    "return the arccosine of the receiver (as radians).
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2656
     Raises an exception, if the receiver is not in -1..1"
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2657
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2658
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2659
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2660
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2661
#if defined(LONG_acos)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2662
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2663
    LONGFLOAT_t val, rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2664
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2665
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2666
    val = __longFloatVal(self);
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2667
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  2668
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2669
    if ((val >= -1.0) && (val <= 1.0))
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2670
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2671
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2672
	__threadErrno = 0;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2673
	rslt = LONG_acos(val);
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2674
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2675
	if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2676
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2677
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2678
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2679
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2680
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2681
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2682
	}
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2683
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2684
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2685
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2686
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2687
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2688
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2689
	^ super arcCos
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2690
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2691
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2692
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2693
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2694
	selector:#arcCos
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2695
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2696
	errorString:'bad receiver in arcCos'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2697
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2698
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2699
     -10 asLongFloat arcCos
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2700
     1 asLongFloat arcCos
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2701
     0.5 asLongFloat arcCos
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2702
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2703
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2704
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2705
arcCosh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2706
    "return the hyperbolic arccosine of the receiver."
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2707
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2708
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2709
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2710
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2711
#if defined(LONG_acosh)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2712
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2713
    LONGFLOAT_t val, rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2714
    OBJ newFloat;
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2715
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2716
    val = __longFloatVal(self);
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2717
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  2718
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2719
    if (val >= 1.0)
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2720
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2721
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2722
	__threadErrno = 0;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2723
	rslt = LONG_acosh(val);
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2724
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2725
	if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2726
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2727
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2728
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2729
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2730
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2731
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2732
	}
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2733
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2734
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2735
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2736
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2737
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2738
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2739
	^ super arcCosh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2740
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2741
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2742
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2743
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2744
	selector:#arcCosh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2745
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2746
	errorString:'bad receiver in arcCosh'
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2747
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2748
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2749
     -10 asLongFloat arcCosh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2750
     1 asLongFloat arcCosh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2751
     0.5 asLongFloat arcCosh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2752
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2753
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2754
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2755
arcSin
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2756
    "return the arcsine of the receiver (as radians).
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2757
     Raises an exception, if the receiver is not in -1..1"
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2758
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2759
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2760
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2761
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2762
#if defined(LONG_asin)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2763
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2764
    LONGFLOAT_t val, rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2765
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2766
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2767
    val = __longFloatVal(self);
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2768
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  2769
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2770
    if ((val >= -1.0) && (val <= 1.0))
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2771
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2772
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2773
	__threadErrno = 0;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2774
	rslt = LONG_asin(val);
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2775
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2776
	if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2777
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2778
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2779
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2780
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2781
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2782
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2783
	}
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2784
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2785
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2786
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2787
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2788
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2789
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2790
	^ super arcSin
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2791
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2792
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2793
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2794
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2795
	selector:#arcSin
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2796
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2797
	errorString:'bad receiver in arcSin'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2798
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2799
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2800
     -10 asLongFloat arcSin
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2801
     1 asLongFloat arcSin
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2802
     0.5 asLongFloat arcSin
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2803
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2804
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2805
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2806
arcSinh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2807
    "return the hyperbolic arcsine of the receiver."
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2808
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2809
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2810
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2811
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2812
#if defined(LONG_asinh)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2813
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2814
    LONGFLOAT_t val, rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2815
    OBJ newFloat;
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2816
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2817
    val = __longFloatVal(self);
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2818
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  2819
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2820
    if (val >= 1.0)
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2821
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2822
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2823
	__threadErrno = 0;
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2824
	rslt = LONG_asinh(val);
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2825
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2826
	if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2827
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2828
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2829
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2830
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2831
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2832
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2833
	}
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2834
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2835
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2836
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2837
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2838
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2839
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2840
	^ super arcSinh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2841
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2842
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2843
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2844
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2845
	selector:#arcSinh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2846
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2847
	errorString:'bad receiver in arcSinh'
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2848
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2849
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2850
     -10 asLongFloat arcSinh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2851
     1 asLongFloat arcSinh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2852
     0.5 asLongFloat arcSinh
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2853
    "
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2854
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2855
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2856
arcTan
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2857
    "return the arctangent of the receiver (as radians)"
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2858
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2859
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2860
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2861
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2862
#if defined(LONG_atan)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2863
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2864
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2865
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2866
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2867
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2868
    rslt = LONG_atan(__longFloatVal(self));
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2869
# ifdef LONG_isnan
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2870
    if (! LONG_isnan(rslt))
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2871
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2872
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2873
	if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2874
	    __qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2875
	    RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2876
	}
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2877
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2878
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2879
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2880
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2881
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2882
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2883
	^ super arcTan
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2884
    ].
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2885
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2886
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2887
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2888
	selector:#arcTan
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2889
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2890
	errorString:'bad receiver in arcTan'
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2891
!
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2892
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2893
arcTanh
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2894
    "return the hyperbolic arctangent of the receiver."
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2895
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2896
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2897
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2898
%{
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2899
#if defined(LONG_atanh)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2900
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2901
    LONGFLOAT_t val, rslt;
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2902
    OBJ newFloat;
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2903
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2904
    val = __longFloatVal(self);
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2905
    __threadErrno = 0;
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19570
diff changeset
  2906
# ifdef __win32__ /* to suppress the warnBox opened by win32 */
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2907
    if ((val >= -1.0) && (val <= 1.0))
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2908
# endif
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2909
    {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2910
	rslt = LONG_atanh(val);
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2911
# ifdef LONG_isnan
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2912
	if (! LONG_isnan(rslt))
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2913
# endif
22790
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  2914
# if defined( __osx__ )
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  2915
	if (LONG_isfinite(rslt))
5791073e4907 atanh fix
Claus Gittinger <cg@exept.de>
parents: 22724
diff changeset
  2916
# endif
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2917
	{
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2918
	    if (__threadErrno == 0) {
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2919
		__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2920
		RETURN ( newFloat );
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2921
	    }
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2922
	}
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2923
    }
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2924
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2925
    useFallBack = true;
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2926
#endif
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2927
%}.
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2928
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2929
	^ super arcTanh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2930
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2931
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2932
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2933
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2934
	selector:#arcTanh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2935
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2936
	errorString:'bad receiver in arcTanh'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2937
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2938
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2939
cos
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2940
    "return the cosine of the receiver (interpreted as radians)"
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2941
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2942
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2943
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2944
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2945
#if defined(LONG_cos)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2946
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2947
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2948
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2949
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2950
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2951
    rslt = LONG_cos(__longFloatVal(self));
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2952
# ifdef LONG_isnan
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2953
    if (! LONG_isnan(rslt))
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2954
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2955
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2956
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2957
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2958
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2959
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2960
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2961
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2962
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2963
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2964
	^ super cos
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2965
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2966
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2967
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2968
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2969
	selector:#cos
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2970
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2971
	errorString:'bad receiver in cos'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2972
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2973
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2974
cosh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2975
    "return the hyperbolic cosine of the receiver"
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2976
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2977
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2978
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2979
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2980
#if defined(LONG_cosh)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2981
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  2982
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2983
    OBJ newFloat;
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  2984
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2985
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2986
    rslt = LONG_cosh(__longFloatVal(self));
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2987
# ifdef LONG_isnan
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2988
    if (! LONG_isnan(rslt))
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2989
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2990
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2991
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2992
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2993
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2994
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  2995
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2996
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  2997
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  2998
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  2999
	^ super cosh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3000
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3001
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3002
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3003
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3004
	selector:#cosh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3005
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3006
	errorString:'bad receiver in cosh'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3007
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3008
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3009
sin
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3010
    "return the sine of the receiver (interpreted as radians)"
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3011
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3012
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3013
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3014
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3015
#if defined(LONG_sin)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3016
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3017
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3018
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3019
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3020
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3021
    rslt = LONG_sin(__longFloatVal(self));
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3022
# ifdef LONG_isnan
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3023
    if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3024
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3025
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3026
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3027
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3028
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3029
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  3030
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3031
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3032
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3033
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3034
	^ super sin
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3035
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3036
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3037
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3038
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3039
	selector:#sin
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3040
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3041
	errorString:'bad receiver in sin'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3042
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3043
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3044
sinh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3045
    "return the hyperbolic sine of the receiver"
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3046
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3047
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3048
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3049
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3050
#if defined(LONG_sinh)
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3051
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3052
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3053
    OBJ newFloat;
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3054
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3055
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3056
    rslt = LONG_sinh(__longFloatVal(self));
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3057
# ifdef LONG_isnan
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3058
    if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3059
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3060
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3061
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3062
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3063
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3064
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  3065
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3066
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3067
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3068
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3069
	^ super sinh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3070
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3071
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3072
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3073
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3074
	selector:#sinh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3075
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3076
	errorString:'bad receiver in sinh'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3077
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3078
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3079
tan
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3080
    "return the tangens of the receiver (interpreted as radians)"
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3081
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3082
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3083
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3084
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3085
#if defined(LONG_tan)
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3086
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3087
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3088
    OBJ newFloat;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3089
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3090
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3091
    rslt = LONG_tan(__longFloatVal(self));
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3092
# ifdef LONG_isnan
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3093
    if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3094
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3095
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3096
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3097
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3098
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3099
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  3100
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3101
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3102
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3103
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3104
	^ super tan
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3105
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3106
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3107
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3108
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3109
	selector:#tan
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3110
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3111
	errorString:'bad receiver in tan'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3112
!
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3113
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3114
tanh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3115
    "return the hyperbolic tangens of the receiver"
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3116
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3117
    |useFallBack|
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3118
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3119
%{
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3120
#if defined(LONG_tanh)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3121
    LONGFLOAT_t rslt;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3122
    OBJ newFloat;
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3123
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3124
    __threadErrno = 0;
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3125
    rslt = LONG_tanh(__longFloatVal(self));
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3126
# ifdef LONG_isnan
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3127
    if (! LONG_isnan(rslt))
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3128
# endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3129
    if (__threadErrno == 0) {
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3130
	__qMKLFLOAT(newFloat, rslt);
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3131
	RETURN ( newFloat );
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3132
    }
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3133
#else
7395
14525c2a9410 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7393
diff changeset
  3134
    useFallBack = true;
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3135
#endif
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3136
%}.
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3137
    useFallBack notNil ifTrue:[
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3138
	^ super tanh
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3139
    ].
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3140
    ^ self class
7731
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3141
	raise:#domainErrorSignal
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3142
	receiver:self
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3143
	selector:#tanh
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3144
	arguments:#()
abbf80b3913b Enable C library functions for windows
Stefan Vogel <sv@exept.de>
parents: 7728
diff changeset
  3145
	errorString:'bad receiver in tanh'
7385
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3146
! !
852e84340d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7383
diff changeset
  3147
5552
31b5cc144476 category changes
Claus Gittinger <cg@exept.de>
parents: 5411
diff changeset
  3148
!LongFloat methodsFor:'truncation & rounding'!
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3150
ceiling
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3151
    "return the smallest integer which is greater or equal to the receiver."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3152
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3153
    |val|
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3154
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3155
%{
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3156
#if defined(LONG_ceil)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3157
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3158
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3159
    lVal = LONG_ceil(__longFloatVal(self));
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3160
    if ((lVal >= (LONGFLOAT_t)_MIN_INT) && (lVal <= (LONGFLOAT_t)_MAX_INT)) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3161
	RETURN ( __mkSmallInteger( (INT) lVal ) );
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3162
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3163
    __qMKLFLOAT(val, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3164
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3165
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3166
    val notNil ifTrue:[
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3167
	^ val asInteger
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3168
    ].
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3169
    ^ super ceiling.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3170
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3171
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3172
     0.5q ceiling
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3173
     -0.5q ceiling
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3174
    "
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3175
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3176
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3177
ceilingAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3178
    "return the smallest integer-valued float greater or equal to the receiver.
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3179
     This is much like #ceiling, but avoids a (possibly expensive) conversion
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3180
     of the result to an integer.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3181
     It may be useful, if the result is to be further used in another float-operation."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3182
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3183
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3184
#if defined(LONG_ceil)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3185
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3186
    OBJ v;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3187
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3188
    lVal = LONG_ceil(__longFloatVal(self));
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3189
    __qMKLFLOAT(v, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3190
    RETURN (v);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3191
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3192
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3193
    ^ super ceilingAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3194
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3195
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3196
     0.5q ceilingAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3197
     -0.5q ceilingAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3198
     -1.5q ceilingAsFloat
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3199
    "
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3200
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3201
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3202
floor
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3203
    "return the integer nearest the receiver towards negative infinity."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3204
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3205
    |val|
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3206
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3207
%{
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3208
#if defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3209
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3210
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3211
    lVal = LONG_floor(__longFloatVal(self));
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3212
    if ((lVal >= (LONGFLOAT_t)_MIN_INT) && (lVal <= (LONGFLOAT_t)_MAX_INT)) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3213
	RETURN ( __mkSmallInteger( (INT) lVal ) );
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3214
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3215
    __qMKLFLOAT(val, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3216
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3217
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3218
    val notNil ifTrue:[
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3219
	^ val asInteger
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3220
    ].
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3221
    ^ super floor.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3222
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3223
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3224
     0.5q floor
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3225
     -0.5q floor
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3226
    "
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3227
!
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3228
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3229
floorAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3230
    "return the float which represents the next lower
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3231
     integer nearest the receiver towards negative infinity.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3232
     Much like floor, but returns a float result - useful if the result
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3233
     will be used in another float operation, to avoid costy int-conversion."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3234
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3235
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3236
#if defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3237
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3238
    OBJ v;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3239
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3240
    lVal = LONG_floor(__longFloatVal(self));
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3241
    __qMKLFLOAT(v, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3242
    RETURN (v);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3243
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3244
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3245
    ^ super floorAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3246
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3247
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3248
     0.5q floorAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3249
     -0.5q floorAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3250
     -1.5q floorAsFloat
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3251
    "
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3252
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3253
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3254
fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3255
    "extract the after-decimal fraction part.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3256
     such that (self truncated + self fractionPart) = self"
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3257
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3258
%{  /* NOCONTEXT */
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3259
#if defined(LONG_modf)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3260
    LONGFLOAT_t frac, trunc;
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3261
    OBJ v;
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3262
19322
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3263
    // mingw64 runtime modfl has a bug, triggering a SEGV
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3264
    // see https://sourceforge.net/p/mingw-w64/bugs/478/
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3265
# if defined(MINGW_MODFL_BUG)
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3266
    {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3267
	LONGFLOAT_t value = __longFloatVal(self);
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3268
	LONGFLOAT_t int_part = LONG_trunc(value);
19329
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  3269
	frac = (isinf (value) ?  0.0L : value - int_part);
19322
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3270
    }
Claus Gittinger <cg@exept.de>
parents: 19268
diff changeset
  3271
# else
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3272
    frac = LONG_modf(__longFloatVal(self), &trunc);
19329
52f5c0de20b4 LongFloat printing under mingw was broken (wrong printf called)
Claus Gittinger <cg@exept.de>
parents: 19324
diff changeset
  3273
# endif
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3274
    __qMKLFLOAT(v, frac);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3275
    RETURN (v);
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3276
#endif
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3277
%}.
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3278
    ^ super fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3279
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3280
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3281
     1.6q fractionPart + 1.6q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3282
     -1.6q fractionPart + -1.6q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3283
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3284
     1.0q fractionPart
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3285
     2.0q fractionPart
14743
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3286
     3.0 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3287
     4.0 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3288
     0.5 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3289
     0.25 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3290
     3.14159 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3291
     12345673.14159 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3292
     123456731231231231.14159 asLongFloat fractionPart
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3293
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3294
     3.14159 asLongFloat fractionPart + 3.14159 asLongFloat truncated
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3295
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3296
     12345673.14159 asLongFloat fractionPart + 12345673.14159 asLongFloat truncated
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3297
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3298
     123456731231231231.14159 asLongFloat fractionPart + 123456731231231231.14159 asLongFloat truncated
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3299
    "
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3300
!
2850b939debd class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14691
diff changeset
  3301
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3302
rounded
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3303
    "return the receiver rounded to the nearest integer"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3304
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3305
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3306
#if defined(LONG_ceil) && defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3307
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3308
    OBJ v;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3309
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3310
    lVal = __longFloatVal(self);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3311
    if (lVal < 0.0) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3312
	lVal = LONG_ceil(lVal - (LONGFLOAT_t)0.5);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3313
    } else {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3314
	lVal = LONG_floor(lVal + (LONGFLOAT_t)0.5);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3315
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3316
    /*
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3317
     * ST-80 (and X3J20) returns integer.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3318
     */
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3319
    if ((lVal >= (LONGFLOAT_t)_MIN_INT) && (lVal <= (LONGFLOAT_t)_MAX_INT)) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3320
	RETURN ( __mkSmallInteger( (INT) lVal ) );
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3321
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3322
    __qMKLFLOAT(v, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3323
    RETURN (v);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3324
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3325
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3326
    ^ super rounded
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3327
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3328
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3329
     0.4q rounded
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3330
     0.5q rounded
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3331
     0.6qqrounded
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3332
     -0.4q rounded
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3333
     -0.5q rounded
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3334
     -0.6q rounded
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3335
    "
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3336
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3337
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3338
roundedAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3339
    "return the receiver rounded to the nearest integer as a float.
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3340
     This is much like #rounded, but avoids a (possibly expensive) conversion
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3341
     of the result to an integer.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3342
     It may be useful, if the result is to be further used in another float-operation."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3343
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3344
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3345
#if defined(LONG_ceil) && defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3346
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3347
    OBJ v;
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3348
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3349
    lVal = __longFloatVal(self);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3350
    if (lVal < 0.0) {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3351
	lVal = LONG_ceil(lVal - (LONGFLOAT_t)0.5);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3352
    } else {
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3353
	lVal = LONG_floor(lVal + (LONGFLOAT_t)0.5);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3354
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3355
    __qMKLFLOAT(v, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3356
    RETURN (v);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3357
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3358
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3359
    ^ super roundedAsFloat
7357
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3360
!
cde54b45c469 full float functionality available (on linux)
Claus Gittinger <cg@exept.de>
parents: 7141
diff changeset
  3361
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3362
truncated
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3363
    "return the receiver truncated towards zero as an integer"
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3364
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3365
    |val|
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3366
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3367
%{
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3368
#if defined(LONG_ceil) && defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3369
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3370
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3371
    lVal = __longFloatVal(self);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3372
    if (lVal < 0.0) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3373
	lVal = LONG_ceil(lVal);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3374
    } else {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3375
	lVal = LONG_floor(lVal);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3376
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3377
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3378
    /*
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3379
     * ST-80 (and X3J20) returns integer.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3380
     */
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3381
    if ((lVal >= (LONGFLOAT_t)_MIN_INT) && (lVal <= (LONGFLOAT_t)_MAX_INT)) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3382
	RETURN ( __mkSmallInteger( (INT) lVal ) );
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3383
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3384
    __qMKLFLOAT(val, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3385
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3386
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3387
    val notNil ifTrue:[
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3388
	^ val asInteger
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3389
    ].
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3390
    ^ super truncated
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3391
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3392
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3393
     0.5q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3394
     -0.5q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3395
     0.5q truncatedAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3396
     -0.5q truncatedAsFloat
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3397
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3400
truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3401
    "return the receiver truncated towards zero as a float.
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3402
     This is much like #truncated, but avoids a (possibly expensive) conversion
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3403
     of the result to an integer.
10333
e441b017d3a1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10319
diff changeset
  3404
     It may be useful, if the result is to be further used in another
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3405
     float-operation."
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3406
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3407
%{  /* NOCONTEXT */
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3408
#if defined(LONG_ceil) && defined(LONG_floor)
24267
3055b5e1373f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 24263
diff changeset
  3409
    LONGFLOAT_t lVal;
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3410
    OBJ v;
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3411
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3412
    lVal = __longFloatVal(self);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3413
    if (lVal < 0.0) {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3414
	lVal = LONG_ceil(lVal);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3415
    } else {
14931
0de2fc03f23a mingw fixes
Claus Gittinger <cg@exept.de>
parents: 14921
diff changeset
  3416
	lVal = LONG_floor(lVal);
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3417
    }
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3418
    __qMKLFLOAT(v, lVal);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3419
    RETURN (v);
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3420
#endif
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3421
%}.
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3422
    ^ super truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3423
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3424
    "
14745
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3425
     0.5q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3426
     -0.5q truncated
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3427
     0.5q truncatedAsFloat
2bad9feb8593 class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14743
diff changeset
  3428
     -0.5q truncatedAsFloat
7382
Claus Gittinger <cg@exept.de>
parents: 7380
diff changeset
  3429
    "
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
! !
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
!LongFloat class methodsFor:'documentation'!
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3434
version
18833
60ea69618028 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18363
diff changeset
  3435
    ^ '$Header$'
12476
66b5104cedc9 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 11925
diff changeset
  3436
!
66b5104cedc9 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 11925
diff changeset
  3437
66b5104cedc9 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 11925
diff changeset
  3438
version_CVS
18833
60ea69618028 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18363
diff changeset
  3439
    ^ '$Header$'
4165
6d83608a7584 initial - not yet tested/released
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3440
! !
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3441
14600
c7cabeb9c3bc class: LongFloat
Stefan Vogel <sv@exept.de>
parents: 14369
diff changeset
  3442
7389
4fd487ca919a longFloat precision constants;
Claus Gittinger <cg@exept.de>
parents: 7385
diff changeset
  3443
LongFloat initialize!