Moin Steve,
On Sunday 06 April 2008 06:51:41 Steve Wills via RT wrote:

Show quoted text> Queue: Math-BigRat
> Ticket <URL:

http://rt.cpan.org/Ticket/Display.html?id=34584 >
>
> HI there,
>
> On Apr 5, 2008, at 5:43 PM, TELS via RT wrote:

> > <URL:

http://rt.cpan.org/Ticket/Display.html?id=34584 >
> >
> > Hi Steve,
> >
> > (via RT so the mail gets recored)
> >
> > So far I found out that it hangs in this operation:
> >
> > $x->bpow($x_org, @params)
> >
> > where $x is:
> >
> > 90933395208605785401971970164779391644753259799242 /
> > 33452526613163807108170062053440751665152000000000
> >
> > and $x is 1/2. This means it needs to take the square root of $x.
> >
> > After a bit of debugging it turns out the general algorithm can't
> > deal with "A/B ** 1/N" - I now added a shortcut that routes these
> > cases through bsqrt() (for 1/2) or broot (for 1/N where N > 2).
> >
> > I made a pre-release package, can you please test it?
> >
> >

http://Bloodgate.com/perl/packages/devel/Math-
> > BigRat-0.22.tar.gz

>
> Thanks for taking a look. I upgraded my Math::BigInt, then ran the

You mean you upgraded your Math::BigRat? ;)

Show quoted text> test code from the bug report. It now doesn't hang, but the results
> aren't what I expect:
>
> # perl exp.pl
> 1/2
> 9535900335500879457687887524133067574481
> /5783815921445270815783609372070483523265

Well:
# perl -Mbignum -wle 'print 9535900335500879457687887524133067574481 /
5783815921445270815783609372070483523265'
1.648721270700128146848650787814163571654
:-D
Math::BigRat routines will generally return Math::BigRat objects - if
they don't, that's a bug (or missing feature :)
You should be able to do normal math with the returned object - that is
the point of Math::BigRat after all.
You can, of course, convert this number to a scalar, but you will lose
digits:
# perl -Mbigrat -wle 'my $a =
9535900335500879457687887524133067574481 /
5783815921445270815783609372070483523265; print $a->numify()'
1.64872127070013

Show quoted text> On a system with the older perl, I get:
>
> # perl exp.pl
> 1/2
> 1.64872127070013
>
> (here, perl is 5.8.6 and Math::BigRat is 0.13)

That's a bug then :)
Fromt the changelog:
2007-06-30 v0.20 Tels 956 tests
* require Math::BigInt v1.87
* add bnok() and bexp()
Hence bexp() and overloading for exp() was added in v0.20 of BigRat.
If you want to use the "normal" exp() from Perl, it is available as
CORE::exp();
perl -Mbigrat -wle 'print CORE::exp("0.5")'
1.64872127070013
Note the quoting of the argument to prevent "bigrat" from turning it
into a Math::BigRat. (This is not nec. if you use Math::BigRat alone,
tho)

Show quoted text> I'm no math expert, but the answer the folks I'm working with I
> believe expect a decimal answer as the older version did.
>
> Also, and again, I'm no math expert, what about broot cases where 1/N
> and N < 2? If I change the test case to 1/1.5, it still hangs.

Ah. Good catch. I think I need to refine the algorithm to handle these
cases, too.

Show quoted text> Again, thanks for taking a look at this, I greatly appreciate it.

No, thank you for your report!
All the best,
Tels
--
Signed on Sun Apr 6 11:01:12 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.
"My glasses, my glasses. I cannot see without my glasses."
- "My
glasses, my glasses. I cannot be seen without my glasses."