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