1
0
Fork 0
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:
Lev Kujawski 2021-02-11 15:25:51 -07:00 committed by Martijn Dekker
parent 0f92d63823
commit d5a94b3722
3 changed files with 25 additions and 2 deletions

View file

@ -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'