Skip to content

Commit

Permalink
test pdl-ising of large negative IV that broke on 32 bit - #469
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Apr 4, 2024
1 parent 377d2a7 commit f57bbe1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Basic/Core/pdlperl.h.PL
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static inline int _pdl_whichdatatype_int(IV iv) {
/* Check minimum, at least double, datatype required to represent number */
static inline int _pdl_whichdatatype_double(NV nv) {
PDL_TESTTYPE(PDL_D,PDL_Double, nv)
PDL_TESTTYPE(PDL_D,PDL_LDouble, nv)
PDL_TESTTYPE(PDL_LD,PDL_LDouble, nv)
#undef PDL_TESTTYPE
return PDL_D; /* handles NaN */
}
Expand Down
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Slatec ezfft* routines take IFAC to avoid treating part of float array as integer (#468)
- add has_badvalue method for whether ndarray has per-pdl badvalue (#469)
- fix Slatec breaking PDL::Stats (https://github.com/PDLPorters/PDL-Stats/issues/31) - thanks @sebastic for report
- fix long-standing mistyping of large negative IVs on 32-bit (#469) - thanks @sebastic for report

2.086 2024-03-31
- fix 64-bit problem in Minuit revealed by LTO (#468) - thanks @eli-schwartz for report
Expand Down
12 changes: 10 additions & 2 deletions t/core.t
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@ my $pdl = pdl $array;
is_deeply( unpdl($pdl), $array, "back convert 3d");
SKIP: {
skip("your perl hasn't 64bit int support", 6) if $Config{ivsize} < 8;
{
my $neg = -684394069604;
my $straight_pdl = pdl($neg);
my $multed = pdl(1) * $neg;
ok $straight_pdl == $multed, 'upgrade of large negative SV to ndarray'
or diag "straight=$straight_pdl mult=$multed\n",
"straight:", $straight_pdl->info, " mult:", $multed->info;
}
my $input = [
-9223372036854775808, #min int64
-9000000000000000001,
Expand Down Expand Up @@ -624,11 +632,11 @@ note "D ($pb * 600) is $pd";
my $pi = 4*atan2(1,1);

my $pe = $pb * $pi;
is($pe->get_datatype, $PDL_D, "E promoted to double (needed to represent result)");
cmp_ok($pe->get_datatype, '>=', $PDL_D, "E promoted to double (needed to represent result)");
note "E ($pb * PI) is $pe";

my $pf = $pb * "-2.2";
is($pf->get_datatype, $PDL_D, "F check string handling");
cmp_ok($pf->get_datatype, '>=', $PDL_D, "F check string handling");
note "F ($pb * string(-2.2)) is $pf";
}

Expand Down

0 comments on commit f57bbe1

Please sign in to comment.