Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.fortran Subject: Re: MAX function, but carry sign Message-ID: <3312@charon.cwi.nl> Date: 13 Apr 91 20:04:37 GMT References: <282@venice.water.ca.gov> <1991Apr12.151728.12916@craycos.com> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 11 In article <1991Apr12.151728.12916@craycos.com> jrbd@craycos.com (James Davies) writes: > In article <282@venice.water.ca.gov> rfinch@caldwr.water.ca.gov (Ralph Finch) writes: > >a=max(abs(a1),abs(a2)) ! but a has sign of either a1 or a2 > > > a = sign(max(abs(a1),abs(a2)), a1+a2) Except this fails if a1+a2 overflows. The other solution I saw is better, although a bit more elaborate. -- dik t. winter, cwi, amsterdam, nederland dik@cwi.nl