mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Produce IEEE compliant output from pow() despite platform deviations
src/cmd/ksh93/features/math.sh: - Specify ast_float.h within iffehdrs instead of math.h, so that iffe will pick up on macro substitutions within libast. This should make any future efforts to remedy floating point behavior easier as well. - Always include ast_float.h within the generated math header file, not just on IA64 platforms. src/cmd/ksh93/tests/arith.sh: - Test pow(1.0,-Inf) and pow(1.0,NaN) for IEEE compliance as well. - Test the exponentiation operator (**) in addition, as streval.c, which processes the same, calls pow() separately. src/lib/libast/features/float: - Test the IEEE compliance of the underlying math library's pow() function and substitute macros producing compliant behavior if necessary.
This commit is contained in:
parent
0f92d63823
commit
d5a94b3722
3 changed files with 25 additions and 2 deletions
|
|
@ -29,7 +29,7 @@ esac
|
|||
|
||||
command=$0
|
||||
iffeflags="-n -v"
|
||||
iffehdrs="math.h"
|
||||
iffehdrs="ast_float.h"
|
||||
iffelibs="-lm"
|
||||
table=/dev/null
|
||||
|
||||
|
|
@ -136,11 +136,11 @@ case $_hdr_ieeefp in
|
|||
1) echo "#include <ieeefp.h>" ;;
|
||||
esac
|
||||
cat <<!
|
||||
#include <ast_float.h>
|
||||
#if defined(__ia64__) && defined(signbit)
|
||||
# if defined __GNUC__ && __GNUC__ >= 4
|
||||
# define __signbitl(f) __builtin_signbitl(f)
|
||||
# else
|
||||
# include <ast_float.h>
|
||||
# if _lib_copysignl
|
||||
# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0)
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -297,6 +297,12 @@ fi
|
|||
if (( (4**3)**2 != pow(pow(4,3),2) ))
|
||||
then err_exit '(4**3)**2 not working'
|
||||
fi
|
||||
if (( 1**Inf != pow(1,Inf) ))
|
||||
then err_exit '1**Inf not working'
|
||||
fi
|
||||
if (( 1**NaN != pow(1,NaN) ))
|
||||
then err_exit '1**NaN not working'
|
||||
fi
|
||||
typeset -Z3 x=11
|
||||
typeset -i x
|
||||
if (( x != 11 ))
|
||||
|
|
@ -465,8 +471,12 @@ then set \
|
|||
(( NaN != NaN )) || err_exit 'NaN == NaN'
|
||||
(( -5*Inf == -Inf )) || err_exit '-5*Inf != -Inf'
|
||||
[[ $(print -- $((sqrt(-1.0)))) == ?(-)nan ]]|| err_exit 'sqrt(-1.0) != NaN'
|
||||
(( pow(1.0,-Inf) == 1.0 )) || err_exit 'pow(1.0,-Inf) != 1.0'
|
||||
(( pow(-Inf,0.0) == 1.0 )) || err_exit 'pow(-Inf,0.0) != 1.0'
|
||||
(( pow(1.0,Inf) == 1.0 )) || err_exit 'pow(1.0,Inf) != 1.0'
|
||||
(( pow(Inf,0.0) == 1.0 )) || err_exit 'pow(Inf,0.0) != 1.0'
|
||||
(( pow(1.0,NaN) == 1.0 )) || err_exit 'pow(1.0,NaN) != 1.0'
|
||||
(( pow(Nan,0.0) == 1.0 )) || err_exit 'pow(Nan,0.0) != 1.0'
|
||||
[[ $(print -- $((NaN/Inf))) == ?(-)nan ]] || err_exit 'NaN/Inf != NaN'
|
||||
(( 4.0/Inf == 0.0 )) || err_exit '4.0/Inf != 0.0'
|
||||
else err_exit 'Inf and NaN not working'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue