386 math library - bug fix
Glenn Geers
glenn at suphys.physics.su.OZ.AU
Mon Nov 19 08:55:21 AEST 1990
Well there was bound to be at least one...
Priority: Urgent
Symptoms: acos crashes with a zero argument and returns incorrect results
for arguments less than 0.
Fix:
Replace the previous version with the one below
---------------------------CUT HERE-------------------------------------------
/*
** This file is part of the alternative 80386 math library and is
** covered by the GNU General Public license.
*/
.align 4
.Lhalfpi:
.double 1.57079632679489661923
.align 4
.globl acos
acos:
pushl %ebp
movl %esp,%ebp
fldl 8(%ebp)
ftst
fstsw %ax
sahf
jz .Lzero
fst %st(1)
fst %st(2)
fmulp
fld1
fsubp
fsqrt
fdivp
fld1
fpatan
jnc .Ldone /* carry set if result of test (above) was -ve */
fldpi
faddp
jmp .Ldone
.Lzero:
fldl .Lhalfpi
.Ldone:
leave
ret
---------------------------CUT HERE-------------------------------------------
Further Comments
----------------
I have coded copysign, cosh, sinh and tanh in assembler. The inverse hyperbolics
will be done soon.
Question
--------
The standard math library returns HUGE (about 1e38) when any of the functions
go over range. Cosh and sinh in particular, do not give any warning when this
happens. My versions give `Floating point exceptions' and crash. Which is the
better behaviour?
Cheers,
Glenn
--
Glenn Geers | "So when it's over, we're back to people.
Department of Theoretical Physics | Just to prove that human touch can have
The University of Sydney | no equal."
Sydney NSW 2006 Australia | - Basia Trzetrzelewska, 'Prime Time TV'
More information about the Comp.unix.sysv386
mailing list