Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Floating point problems
@ 1998-11-28 13:15 Heinz Ulrich Stille
  1998-11-28 14:24 ` Johannes G.D. Hausmann
  0 siblings, 1 reply; 24+ messages in thread
From: Heinz Ulrich Stille @ 1998-11-28 13:15 UTC (permalink / raw)
  To: axp-list

Hi!

What's wrong with the following program?

main() {
	double x = 1.0;
	x *= 1e-310;
}

This results in a floating point exception on my Ruffian (for values
somwhere between 1e-300 and 1e-325, independent of kernel and compiler),
but not on any intel. The assembler output seems to indicate that the
two values are just loaded into registers and multiplied.
What is going on?

MfG, Ulrich

--
"If you were a boy I'd say are you going to seek your fortune?" "Can't girls
seek their fortune?" "I think they're supposed to seek a boy with a fortune."
                                               T. Pratchett, "Equal Rites"


^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: Floating point problems
@ 1998-11-30  8:16 y0000218
  1998-11-30  9:08 ` Carles Perello
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: y0000218 @ 1998-11-30  8:16 UTC (permalink / raw)


Heinz Ulrich Stille <Heinz.Ulrich.Stille@mbi-os.de> wrote:
: Hi!

: What's wrong with the following program?

: main() {
: 	double x = 1.0;
: 	x *= 1e-310;
: }

: This results in a floating point exception on my Ruffian (for values
: somwhere between 1e-300 and 1e-325, independent of kernel and compiler),
: but not on any intel. The assembler output seems to indicate that the
: two values are just loaded into registers and multiplied.
: What is going on?


This looks _very_ familiar - I had the same problem, same range of numbers.

It still reproducibly FP-exeptions on a RH 5.2 system here.

I think its weird, and noone could plausibly tell me why yet.

-mieee works, also fixing my code so it doesnt produce such
small numbers did it.

Could any guru tell me _why_ this code crashes?

Just doing anything with a number around 1e-310 raises an FP exception,
smaller _and_ larger numbers dont.

Olaf

-- 
"The number of Unix installations       Olaf Schnapauff,
has grown to 10, with more expected."   O.Schnapauff@tu-bs.de  
- The Unix Programmer's Manual,1972     http://www.tu-bs.de/~c0033014/
       See Web page and keyservers  for pgp public key


^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: Floating point problems
@ 1998-11-30 10:24 y0000218
  1998-11-30 13:30 ` Alvin Starr
  0 siblings, 1 reply; 24+ messages in thread
From: y0000218 @ 1998-11-30 10:24 UTC (permalink / raw)


Joachim Wesner <joachim.wesner@frankfurt.netsurf.de> wrote:
: denormalized handling maybe somewhat complicated, BUT a hardware option
: that silently replaces/treats any denormal by/like zero would sure have
: costed very few transistors and would have helped critical code alot, if
: you really need the full precision, you could still activate the
: trapping and use -mieee.

: Joachim

Hmm, so whats the "right" way to do this if I dont need the
full precision? (RayTracing doesnt really, whats not visible isnt important).
Currently I do check for "smaller than <some constant>" in critical places
and set things to 0. Nasty. But -mieee seems worse performance-wise.
The worst thing is that I _think_ I check in critical places
and things _usually_ work but i can guarantee it.

Olaf


-- 
"The number of Unix installations       Olaf Schnapauff,
has grown to 10, with more expected."   O.Schnapauff@tu-bs.de  
- The Unix Programmer's Manual,1972     http://www.tu-bs.de/~c0033014/
       See Web page and keyservers  for pgp public key


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~1998-12-03 23:49 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-11-28 13:15 Floating point problems Heinz Ulrich Stille
1998-11-28 14:24 ` Johannes G.D. Hausmann
1998-11-28 13:58   ` Heinz Ulrich Stille
1998-11-28 14:48     ` Stefan Schroepfer
1998-11-28 14:57       ` Heinz Ulrich Stille
1998-11-29 13:15         ` Johannes G.D. Hausmann
1998-11-29 13:02           ` Heinz Ulrich Stille
1998-11-29 18:01           ` B. James Phillippe
  -- strict thread matches above, loose matches on Subject: below --
1998-11-30  8:16 y0000218
1998-11-30  9:08 ` Carles Perello
1998-11-30  9:53 ` Joachim Wesner
1998-11-30 14:22   ` Alvin Starr
1998-11-30 13:27     ` krebs
1998-11-30 17:06 ` Joachim Wesner
1998-12-03  0:48   ` Richard Henderson
1998-12-03 16:59     ` Greg Lindahl
1998-12-03 19:35       ` Joachim Wesner
1998-12-03 20:04       ` Richard Henderson
1998-12-03 20:16         ` Greg Lindahl
1998-12-03 23:44         ` Joachim Wesner
1998-12-01  8:42 ` Jochen Kuepper
1998-11-30 10:24 y0000218
1998-11-30 13:30 ` Alvin Starr
1998-12-03  0:48   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox