develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #61754] 'Data::Dumper' reports double value as string.

Thread Previous
From:
Tony Cook via RT
Date:
June 26, 2013 01:47
Subject:
[perl #61754] 'Data::Dumper' reports double value as string.
Message ID:
rt-3.6.HEAD-2552-1372211244-494.61754-15-0@perl.org
On Sun Feb 03 10:34:34 2013, jkeenan wrote:
> Discussion in this RT petered out about twelve months ago.
> 
> Are there any changes to code or documentation which we should still be
> considering?

I've updated the status to mark the patch as rejected based on the
discussion.

Nicholas complained that:

> I don't think that we should change behaviour to use floating point
literals.
> If we did this, we'd implicitly add a round trip conversion in the reading
> code (parser converts decimals to binary floating point, sv_2pv() converts
> binary floating point back to decimal), which may introduce errors.

but the current mechanism:

a) already does a round trip, if the user supplied the data as a float,
presumably they expect to use it as a float in the code that uses the
value, so it will need to be converted.

b) already introduces errors:

tony@mars:.../git/perl$ ./perl -Ilib -MData::Dumper -e 'print
Dumper(1.0000000000000001)'
$VAR1 = '1';
tony@mars:.../git/perl$ perl -le 'print 1.0000000000001-1'
9.99200722162641e-14

Fixing that is little more complex than the supplied though - possibly
keep adding digits until values match.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=61754

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