From owner-freebsd-current Mon Mar 6 15:26: 6 2000 Delivered-To: freebsd-current@freebsd.org Received: from alcanet.com.au (mail.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id 6269337BBC5 for ; Mon, 6 Mar 2000 15:26:00 -0800 (PST) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <115208>; Tue, 7 Mar 2000 10:26:43 +1100 Content-return: prohibited From: Peter Jeremy Subject: Re: [ID 20000306.004] unpack(NaN) big baddaboom In-reply-to: <200003061831.OAA74965@systemics.com>; from iang@systemics.com on Tue, Mar 07, 2000 at 05:35:04AM +1100 To: Ian Grigg Cc: perl5-porters@perl.org, current@FreeBSD.ORG Message-Id: <00Mar7.102643est.115208@border.alcanet.com.au> MIME-version: 1.0 X-Mailer: Mutt 1.0i Content-type: text/plain; charset=us-ascii References: <200003061831.OAA74965@systemics.com> Date: Tue, 7 Mar 2000 10:26:42 +1100 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Mar-07 05:35:04 +1100, Ian Grigg wrote: >my $packed = "\0\0\xc0\x7f"; >print STDERR "len: ", length($packed), " bytes: ", unpack("H*", $packed), "\n"; >my $float = unpack("f", $packed); >print STDERR "float done\n"; >print STDERR "float: $float\n"; Looking at the resultant core file, perl is getting SIGFPE inside cast_i32() (probably when it tries to cast the NaN to an int). Unfortunately, the code for cast_i32() does not handle NaNs (though it does handle infinity). (And it's not clear what integer value should be associated with NaN in any case). As to whether it should trap or not, that is less clear-cut. FreeBSD takes the view that trying to convert a NaN into an integer is not a sensible operation, so it signals SIGFPE (the i386 NPX gives an invalid operand exception). Other implementations may differ. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message