Date: Tue, 7 Mar 2000 10:26:42 +1100 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: Ian Grigg <iang@systemics.com> Cc: perl5-porters@perl.org, current@FreeBSD.ORG Subject: Re: [ID 20000306.004] unpack(NaN) big baddaboom Message-ID: <00Mar7.102643est.115208@border.alcanet.com.au> In-Reply-To: <200003061831.OAA74965@systemics.com>; from iang@systemics.com on Tue, Mar 07, 2000 at 05:35:04AM %2B1100 References: <200003061831.OAA74965@systemics.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2000-Mar-07 05:35:04 +1100, Ian Grigg <iang@systemics.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00Mar7.102643est.115208>