🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: sci.math.num-analysis
2 messages
2 total messages Started by Eric Kostelich Tue, 12 Sep 1995 17:02
Robust division subroutine
#1166
Author: Eric Kostelich
Date: Tue, 12 Sep 1995 17:02
32 lines
1825 bytes
I want to write a C routine like

	int safediv(double x, double y, double *result)

that performs the computation

	*result = x/y

when x and y are valid floating-point doubles and x/y can be represented
on the processor without overflow or underflow.  (I'm interested in machines
that implement IEEE arithmetic.)
	Of course, a number of errors could occur:  x and y might be NaN's,
y might be 0, or x/y might overflow or underflow.  In such cases, I want
savediv to return a negative value without raising an arithmetic exception.
Otherwise, if x/y can be computed, savediv should put the ratio in *result
and return 0.  In other words, to the extent feasible, I'd like to have
a bulletproof division subroutine.
	My questions:
	(1)  is there a library of similar routines that is publicly available?
	(2)  if not, what is the best way to go about writing such a routine?
	     Robustness is more important than speed for my application.
	(3)  Is there a portable way to implement this routine?  By
	     "portable" I mean a routine that operates on, say, Sun Solaris,
	     IBM AIX, SGI Irix, DEC Alpha and HP-UX workstations.

	Other requirements:
	savediv should operate the same way regardless of how the remainder
	of the program treats floating point exceptions, and the routine
	must not affect how the remainder of the program treats floating
	point exceptions.

All insights and suggestions are appreciated.
Re: Robust division subroutine
#1167
Author: newton love
Date: Tue, 12 Sep 1995 22:22
36 lines
1657 bytes
In article <434ef2$210@keck2.umd.edu>,
Eric Kostelich <kostelic@Glue.umd.edu> wrote:
>I want to write a C routine like
>	int safediv(double x, double y, double *result)


Is this like "Not Re-Invented Here" or what.

Hop on your bad motor scooter, and ride on over to
http://www.yahoo.com/

Surf through the topics until you get to Math libraries.
The CERN archives have source code on this stuff that has
been shown to be bulletproof long, long ago, when you were
still wet behind the ears. . . Hey, What's that?  i can
still see you dripping!

i can't believe how september it is getting!  Rather than 
doing a little research (as in search, and search again!), 
people just jump to their favorite 60 plus news groups and 
spew bits all over the bandwidth.

Look before you spew, dude!  You will getr a lot better (nicer)
response from net denizens if you say "i have been to the
archives, and found the algol and fortran code for a 
"safe" division routine.  Does anyone have a C version?"
.  So, try surfing, before you go beggin.

JMHO
-newt
.

-- 
The SLUUG home: http://dark.wustl.edu/
Home away from home: http://dark.wustl.edu/~newton/
Links to the UNIX world: http://dark.wustl.edu/~newton/othr_uug.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads