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

[perl #128843] printf %a mishandles subnormals

Thread Previous
Tony Cook via RT
August 10, 2016 04:50
[perl #128843] printf %a mishandles subnormals
Message ID:
On Thu Aug 04 13:51:17 2016, 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. */


via perlbug:  queue: perl5 status: new

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About