Skip Menu |

This queue is for tickets about the Math-BigFloat CPAN distribution.

Report information
The Basics
Id: 39682
Status: open
Priority: 0/
Queue: Math-BigFloat

People
Owner: Nobody in particular
Requestors: MARKOV [...] cpan.org
Cc:
AdminCc:

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



Subject: accept INF/+INF/-INF
XML defines huge integers and floats, and my XML::Compile therefore uses Math::BigInt and Math::BigFloat to represent them. Translating the Math::* repr of infinite is expensive, though, because XML uses [+-]?INF, not [+-]inf. My request is twofold (1) please accept captilized INF # handle '+inf', '-inf' first - if ($wanted =~ /^[+-]?inf\z/) - { return $downgrade->new($wanted) if $downgrade; - $self->{sign} = $wanted; + if ($wanted =~ /^[+-]?inf\z/i) + { return $downgrade->new(lc $wanted) if $downgrade; + $self->{sign} = lc $wanted; (2) some output optimization: now I have to recheck your module's output for 'inf' to capitalize it. The complication is that 'NaN' is written with a small 'a' :(
Subject: Re: [rt.cpan.org #39682] accept INF/+INF/-INF
Date: Tue, 30 Sep 2008 20:50:55 +0200
To: bug-Math-BigFloat [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
Moin, On Monday 29 September 2008 12:57:34 Mark Overmeer via RT wrote: Show quoted text
> Mon Sep 29 06:57:33 2008: Request 39682 was acted upon. > Transaction: Ticket created by MARKOV > Queue: Math-BigFloat > Subject: accept INF/+INF/-INF > Broken in: (no value) > Severity: Wishlist > Owner: Nobody > Requestors: MARKOV@cpan.org > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39682 > > > > XML defines huge integers and floats, and my XML::Compile therefore > uses Math::BigInt and Math::BigFloat to represent them. Translating > the Math::* repr of infinite is expensive, though, because XML uses > [+-]?INF, not [+-]inf. > > My request is twofold > > (1) please accept captilized INF > > # handle '+inf', '-inf' first > - if ($wanted =~ /^[+-]?inf\z/) > - { return $downgrade->new($wanted) if $downgrade; > - $self->{sign} = $wanted; > + if ($wanted =~ /^[+-]?inf\z/i) > + { return $downgrade->new(lc $wanted) if $downgrade; > + $self->{sign} = lc $wanted;
That should probably run by the perl5porters mailinglist, as the "inf" and "-inf" are the things that perl accepts, and I am not sure what would speak against or for accepting "INF", too. I guess at the same time "infinity" should also be accepted, Perl however, seems to accept anything starting with "inf" like "infbar" (which I find kinda silly, tho). $ perl -wle 'print 1+INF+1' inf $ perl -wle 'print 1+inf+1' Unquoted string "inf" may clash with future reserved word at -e line 1. inf Show quoted text
> (2) some output optimization: now I have to recheck your module's > output for 'inf' to capitalize it. The complication is that > 'NaN' is written with a small 'a' :(
I am not sure why that is a complication :) However, NaN is what Perl uses, so BigInt just mirrors this. Please note that you can create a subclass of BigInt, and could overload that behaviour. (I am not sure, tho, if a subclass would be easy, because "NaN" could be used all over the place - IIRC I used a constant for it, but my memory may be faulty). All the best, Tels -- Signed on Tue Sep 30 20:47:08 2008 with key 0x93B84C15. Get one of my photo posters: http://bloodgate.com/posters PGP key on http://bloodgate.com/tels.asc or per email. Finagle's First Law: If an experiment works, something has gone wrong.
Download signature.asc
application/pgp-signature 481b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #39682] accept INF/+INF/-INF
Date: Tue, 30 Sep 2008 21:09:19 +0200
To: "nospam-abuse [...] bloodgate.com via RT" <bug-Math-BigFloat [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* RT (bug-Math-BigFloat@rt.cpan.org) [080930 18:53]: Show quoted text
> That should probably run by the perl5porters mailinglist, as the "inf" > and "-inf" are the things that perl accepts, and I am not sure what > would speak against or for accepting "INF", too. > > $ perl -wle 'print 1+INF+1' > inf > $ perl -wle 'print 1+inf+1' > Unquoted string "inf" may clash with future reserved word at -e line 1. > inf
Wow, this is unexpected! "inf" is a value, not a constant (IMO) Show quoted text
> > (2) some output optimization: now I have to recheck your module's > > output for 'inf' to capitalize it. The complication is that > > 'NaN' is written with a small 'a' :(
> > I am not sure why that is a complication :) However, NaN is what Perl > uses, so BigInt just mirrors this.
You mis-understood. What I mean is that I need the INF in capitals. The easiest trick would be: uc $big->bstr Which does not hurt the exponent, but does hurt the NaN. Now I need an expensive check on the object type and m/^([+-])?inf$/ The bstr() method is quite too large to extend simply for getting caps. Besides, I do not want to teach people to use my private BigFloat type. I do not no whether this can be solved. And how about the C back-end? -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
RT-Send-CC: nospam-abuse [...] bloodgate.com
On Tue Sep 30 14:53:55 2008, nospam-abuse@bloodgate.com wrote: Show quoted text
> I guess at the same time "infinity" should also be accepted, Perl > however, seems to accept anything starting with "inf" like "infbar" > (which I find kinda silly, tho).
No, quite the contrary, this is consistent with how Perl works. When Perl is given a string in numeric context, it parses as much of the string as possible and uses that (and also gives a warning). For instance, $ perl -wle 'print 3 + "0.14xyz"' Argument "0.14xyz" isn't numeric in addition (+) at -e line 1. 3.14 and $ perl -wle 'print hex "0x3xyz"' Illegal hexadecimal digit 'x' ignored at -e line 1. 3 The Math::Big* distributions should have done the same. Instead, they return NaN unless the *whole* string is OK. This is inconsistent with core Perl, and it makes it hard to make Math::Big*, bignum, and bigint, work seamlessly with core Perl without breaking backwards compatibility.
Subject: Re: [rt.cpan.org #39682] accept INF/+INF/-INF
Date: Mon, 21 Mar 2011 16:00:17 -0400
To: bug-Math-BigFloat [...] rt.cpan.org
From: "Tels" <nospam-abuse [...] bloodgate.com>
On Mon, March 14, 2011 2:58 pm, Peter John Acklam via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=39682 > > > On Tue Sep 30 14:53:55 2008, nospam-abuse@bloodgate.com wrote: >
>> I guess at the same time "infinity" should also be accepted, Perl >> however, seems to accept anything starting with "inf" like "infbar" >> (which I find kinda silly, tho).
> > No, quite the contrary, this is consistent with how Perl works. When > Perl is given a string in numeric context, it parses as much of the > string as possible and uses that (and also gives a warning). For instance, > > $ perl -wle 'print 3 + "0.14xyz"' > Argument "0.14xyz" isn't numeric in addition (+) at -e line 1. > 3.14 > > and > > $ perl -wle 'print hex "0x3xyz"' > Illegal hexadecimal digit 'x' ignored at -e line 1. > 3 > > The Math::Big* distributions should have done the same. Instead, they > return NaN unless the *whole* string is OK. This is inconsistent with > core Perl, and it makes it hard to make Math::Big*, bignum, and bigint, > work seamlessly with core Perl without breaking backwards compatibility.
The decision was done exactly because I though that accepting "infbar" as well as "InfitiyFoobarNoodles" silently as "inf" is silly. Of course, you can disgree with that and change all that, I just wanted to give the perspective why it was done this way. :) Tels Show quoted text
>
-- http://bloodgate.com/wiki/
RT-Send-CC: solutions [...] overmeer.net, nospam-abuse [...] bloodgate.com
This is fixed. Math-Big(Int|Float) now accepts the same representations of infinity as core Perl does, which includes "-INF", "+INF", and "INF". TELS, please close this ticket or give me permission to do so. Thanks in advance.