[comp.unix.sysv386] 386 math library - bug fix

glenn@suphys.physics.su.OZ.AU (Glenn Geers) (11/19/90)

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'

seanf@sco.COM (Sean Fagan) (11/20/90)

In article <1990Nov18.215521.10762@metro.ucc.su.OZ.AU> glenn@suphys.physics.su.OZ.AU (Glenn Geers) writes:
>/*
>** This file is part of the alternative 80386 math library and is
>** covered by the GNU General Public license.
>*/

Folks, please remember what this means before you use it.

-- 
-----------------+
Sean Eric Fagan  | "*Never* knock on Death's door:  ring the bell and 
seanf@sco.COM    |   run away!  Death hates that!"
uunet!sco!seanf  |     -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422   | Any opinions expressed are my own, not my employers'.