Skip to content

Commit

Permalink
Add $PDL::indxformat for PDL_Indx
Browse files Browse the repository at this point in the history
This avoids loss of significance when 64bit PDL_Indx
values are printed.
  • Loading branch information
devel-chm committed Nov 13, 2015
1 parent 1771693 commit 296270d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Basic/Core/Core.pm
Expand Up @@ -41,6 +41,7 @@ $PDL::verbose = 0;
$PDL::use_commas = 0; # Whether to insert commas when printing arrays
$PDL::floatformat = "%7g"; # Default print format for long numbers
$PDL::doubleformat = "%10.8g";
$PDL::indxformat = "%12d"; # Default print format for PDL_Indx values
$PDL::undefval = 0; # Value to use instead of undef when creating PDLs
$PDL::toolongtoprint = 10000; # maximum pdl size to stringify for printing

Expand Down Expand Up @@ -257,7 +258,7 @@ Whether to insert commas when printing pdls
=back
=head3 C<$PDL::floatformat>, C<$PDL::doubleformat>
=head3 C<$PDL::floatformat>, C<$PDL::doubleformat>, C<$PDL::indxformat>
=over 4
Expand All @@ -266,6 +267,7 @@ The default default values are:
$PDL::floatformat = "%7g";
$PDL::doubleformat = "%10.8g";
$PDL::indxformat = "%12d";
=back
Expand Down Expand Up @@ -3448,6 +3450,7 @@ sub str1D {
my $dtype = $self->get_datatype();
$dformat = $PDL::floatformat if $dtype == $PDL_F;
$dformat = $PDL::doubleformat if $dtype == $PDL_D;
$dformat = $PDL::indxformat if $dtype == $PDL_IND;

my $badflag = $self->badflag();
for $t (@$x) {
Expand Down Expand Up @@ -3502,6 +3505,8 @@ sub str2D{
$format = $PDL::floatformat;
} elsif ($dtype == $PDL_D) {
$format = $PDL::doubleformat;
} elsif ($dtype == $PDL_IND) {
$format = $PDL::indxformat;
} else {
# Stick with default
$findmax = 0;
Expand Down

0 comments on commit 296270d

Please sign in to comment.