develooper Front page | perl.perl5.porters | Postings from August 2016

[perl #128843] printf %a mishandles subnormals

Thread Previous
From:
Tony Cook via RT
Date:
August 10, 2016 04:50
Subject:
[perl #128843] printf %a mishandles subnormals
Message ID:
rt-4.0.24-380-1470804619-1399.128843-15-0@perl.org
On Thu Aug 04 13:51:17 2016, zefram@fysh.org wrote:

> $ perl -lwe 'printf "%a\n", 3e-320'
> 0x1.00000000017b8p-1062
> 
> This output is numerically incorrect.  This happens for any subnormal
> floating-point value.  The output is a mixture of two ways of
> correctly
> describing the value: it is 0x0.00000000017b8p-1022 (displaying
> the physical structure of a subnormal) or 0x1.7b8p-1062 (consistent
> scientific style).

The handling of the implicit one bit is incorrect too. 

> $ perl -MData::Float=float_hex -lwe 'print float_hex(3e-320,
> {subnormal_strategy=>$_}) for qw(SUBNORMAL NORMAL)'
> +0x0.00000000017b8p-1022
> +0x1.7b80000000000p-1062

It looks like subnormals simply weren't implemented:

    /* XXX Inf/NaN/denormal handling in the HEXTRACT_IMPLICIT_BIT,
     * and elsewhere. */

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=128843

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About