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