9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Federico G. Benavento" <benavento@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] float overflow
Date: Fri, 26 Mar 2010 09:54:55 -0300	[thread overview]
Message-ID: <32d987d51003260554p78bc2837ve302822e3ce72d41@mail.gmail.com> (raw)
In-Reply-To: <138575261003260458l18239e6cm9cce321b273d18d@mail.gmail.com>

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 <uair00@gmail.com> 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



  parent reply	other threads:[~2010-03-26 12:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26 11:58 hugo rivera
2010-03-26 12:43 ` erik quanstrom
2010-03-26 12:44 ` maht
2010-03-26 12:54 ` Federico G. Benavento [this message]
2010-03-26 13:37   ` hugo rivera
2010-03-26 16:44 ` ron minnich
2010-03-26 16:57   ` hugo rivera
2010-03-26 17:01     ` erik quanstrom
2010-03-26 17:05     ` ron minnich
2010-03-26 17:05       ` ron minnich
2010-03-26 17:22         ` hugo rivera
2010-03-26 17:46       ` Tim Newsham
2010-03-26 20:23         ` ron minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32d987d51003260554p78bc2837ve302822e3ce72d41@mail.gmail.com \
    --to=benavento@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).