Skip Menu |

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 77457
Status: open
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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



Subject: overloaded numeric types
Date: Sun, 27 May 2012 09:48:29 +1000
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
I'd be good if List::Util min() and max() compared their arguments using the normal perl "<" or ">" so that overloaded number types like Math::BigInt can have a min or max taken. Likewise sum() adding up numbers. Not sure if perl makes those operations available, as sv_ncmp() or whatever. If not it'd be good if it or ppport.h did since they'd probably be helpful in other places too.
Subject: Re: [rt.cpan.org #77457] overloaded numeric types
Date: Tue, 29 May 2012 13:27:46 -0500
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
min/max do work with overloaded types, there are even tests that use Math::BigInt. Are you seeing a specific issue? If so please post an example that is failing
Subject: Re: [rt.cpan.org #77457] overloaded numeric types
Date: Thu, 31 May 2012 08:24:21 +1000
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Show quoted text
> If so please post an example that is failing
A thousand pardons, I lept to a wrong conclusion. But what I think I've got is: With recent i386 debian 5.14.3 with IV=UV=8byte longlong and NV=8byte double, the program foo.pl below prints 18446744073709551600 18446744073709551601 where I expected the two min() returns to be the same, the smaller value, 18446744073709551600 18446744073709551600 This latter is given by the commented-out $TESTING_PERL_ONLY. I wonder if UV has rounded-off stored to "NV retval". I see perl's pp_lt() has cases for UV,IV and RV to preserve the range when int bigger than float. I suppose that happens on alpha and maybe other 64-bit systems even without the recent UV=longlong bloat. Perhaps min() and max() could do the same as pp_lt, or call it, to preserve integer range.
#!/usr/bin/perl -w use strict; # BEGIN { $List::Util::TESTING_PERL_ONLY = 1 } use List::Util 'min'; my $x = ~0 - 15; my $y = ~0 - 14; print min($x,$y),"\n"; print min($y,$x),"\n";
-- Some people say cricket is like watching grass grow. Firstly that's not true as usually the grass is dying on the wicket, and secondly International Rules Grass Growing is much pacier. Cricket goes 5 days and ends in a draw, grass growing is 4 days and sure to have a result.
On Wed May 30 18:25:31 2012, user42@zip.com.au wrote: Show quoted text
> I wonder if UV has rounded-off stored to "NV retval". I see perl's > pp_lt() has cases for UV,IV and RV to preserve the range when int bigger > than float. I suppose that happens on alpha and maybe other 64-bit > systems even without the recent UV=longlong bloat. Perhaps min() and > max() could do the same as pp_lt, or call it, to preserve integer range.
I suspect so; this looks to be another case of RT 95902 -- Paul Evans