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