Skip Menu |
 

This queue is for tickets about the Devel-Peek CPAN distribution.

Report information
The Basics
Id: 131180
Status: open
Priority: 0/
Queue: Devel-Peek

People
Owner: Nobody in particular
Requestors: garikz [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Precision issue on dumping NVs
Download (untitled) / with headers
text/plain 800b
Hello! It seems that Devel::Peek (and Data::Dumper as well) uses some different precision settings when dumping the NV scalars. This renders the output utterly confusing and makes debugging really hard. Tried with Devel::Peek 1.08 and 1.26 Thank you! #!/usr/bin/perl use v5.16; use Data::Dumper; use Devel::Peek; $|++; $Data::Dumper::Terse = 1; my $str_15_digits = '100.000000000000001'; my $str_14_digits = '100.00000000000001'; my $num_14_digits = 100.00000000000001; my $num_13_digits = 100.0000000000001; my $num_12_digits = 100.000000000001; my @r = ($str_15_digits, $str_14_digits, $num_14_digits, $num_13_digits, $num_12_digits); say ( (Dumper($_) =~ s/\n$//r) . ($_ > 100 ? ' is greater than 100' : '') ) for @r; say 'Looking a bit deeper:'; Dump($_) for @r
CC: ;
Subject: Re: [rt.cpan.org #131180] Precision issue on dumping NVs
Date: Mon, 16 Dec 2019 17:15:21 -0800
To: Igor Zakharov via RT <bug-Devel-Peek [...] rt.cpan.org>
From: Ilya Zakharevich <nospam-abuse [...] ilyaz.org>
On Mon, Dec 16, 2019 at 09:36:41AM -0500, Igor Zakharov via RT wrote: Show quoted text
> It seems that Devel::Peek (and Data::Dumper as well) uses some > different precision settings when dumping the NV scalars.
Different from WHAT? Show quoted text
> This renders the output utterly confusing and makes debugging really > hard.
Before looking at claims like this, I would prefer seeing your understanding of how the Perl numeric values are assumed to work. For example: does the behavior you observe differ from integer/string conversions made by Perl? (Perl is mainly a string-processing language, and these requirements were taking precedence in design decisions…) (As a hindsight, it may make sense to unload all the responsibility to the user, and allow something like $Data::Dumper::NVfullPrecision = 1 etc. Do not know how to implement this portably. May need to rely on IEEE conformance if math.h is too dumb… If you want to implement this, one needs a delicate test suite similar to what you did below — but with much smaller step.) Ilya


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.