From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <138575261003260458l18239e6cm9cce321b273d18d@mail.gmail.com> References: <138575261003260458l18239e6cm9cce321b273d18d@mail.gmail.com> Date: Fri, 26 Mar 2010 09:54:55 -0300 Message-ID: <32d987d51003260554p78bc2837ve302822e3ce72d41@mail.gmail.com> From: "Federico G. Benavento" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] float overflow Topicbox-Message-UUID: f3a3ac6a-ead5-11e9-9d60-3106f5b1d025 garbage in, garbage out lotte% echo 1.75e308+1.75e308 | hoc hoc 730809: suicide: sys: fp: numeric overflow fppc=0x3004 status=0xb988 pc=0x3a75 lotte% if you want to keep feeding garbage to your program disable the exceptions see getfcr(2) or http://plan9.bell-labs.com/magic/man2html/2/getfcr setfcr(getfcr()&~(FPINVAL)); feel free to turn division by 0 trap too On Fri, Mar 26, 2010 at 8:58 AM, hugo rivera wrote: > Hello, > float operations are causing me some headaches on plan 9 (9vx). > I have a program that crashes badly when I feed it with near-the-top > doubles ~1.1e308. This causes an overflow in a function that needs to > square this values and acid points the line where the first call to > pow(2) occurs when I debug it. The problem is that this doesn't happen > at all when the program is compiled with gcc (9c) on linux. Obviously > my results aren't useful, but I get '+Inf' on my output and the > program doesn't crash. I thought of using isInf(2) to avoid Infs in my > operations, but this would make the code really ugly and probably > slow. > I've seen that hoc also suffers from this. On 9vx > > % echo 1.75e308+1.75e308 | hoc > hoc 851: suicide: sys: trap: 19 (reserved) pc=0x00003a75 > > but on linux > > echo 1.75e308+1.75e308 | hoc > +Inf > > is there something I can do to remedy this situation? maybe this > doesn't happen on a native plan 9 installation, but I don't have > access to any. > Saludos, > > -- > Hugo > > -- Federico G. Benavento