Subject: | XS's minmax() sometimes return undef (perl >= 5.20) |
% perl -MList::MoreUtils=minmax -MData::Dump -e'for(1..20) { my ($min, $max) = minmax(sprintf("%.4g", rand)); dd ($min,$max) }'
(0.1824, 0.1824)
(0.9667, 0.9667)
(0.9628, 0.9628)
(0.493, undef)
(0.08401, 0.08401)
(0.4284, 0.4284)
(0.01188, 0.01188)
(0.469, undef)
(0.2213, 0.2213)
(0.9549, 0.9549)
(0.3523, 0.3523)
(0.5689, 0.5689)
(0.285, undef)
(0.7718, 0.7718)
(0.2286, 0.2286)
(0.3367, 0.3367)
(0.7222, 0.7222)
(0.476, undef)
(0.1387, 0.1387)
(0.2435, 0.2435)
Happens more often when I use sprintf format "%.3g". Always happens when I use "%.2g" or fewer digits. Also happens when I use sprintf format "f".
Tested with List::MoreUtils 0.413. Doesn't happen with PP backend.
Tested with perl 5.22 and perl 5.20. Doesn't happen with perl 5.18 or earlier.
Ref: http://perlmonks.org/?node_id=1157951