Subject: | Problem with operator values being changed |
Date: | Sat, 15 Apr 2017 09:34:07 +0100 |
To: | bug-math-bigrat [...] rt.cpan.org |
From: | Paul Haffenden <haffread [...] gmail.com> |
Hello,
I'm using strawberry perl on windows 7
This is perl 5, version 24, subversion 1 (v5.24.1) built for
MSWin32-x86-multi-thread-64int
Copyright 1987-2017, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
And I'm having a problem with this little piece of example code, in that
$maxpts is getting
changed unexpectedly after the multiplication:
==============================
use strict;
use warnings;
use Math::BigRat;
sub main
{
my($pts) = Math::BigRat->new("61/4");
my($maxpts) = Math::BigRat->new("40/1");
print("BigRat varsion: $Math::BigRat::VERSION\n");
my($tmp) = $pts->copy();
print("$tmp $maxpts\n");
$tmp = $tmp * $maxpts;
print("$tmp $maxpts\n");
}
main();
exit(0);
======================
When I run it I get:
BigRat varsion: 0.2612
61/4 40
610 10
But if I change the initial value of $maxpts to '5/1' say, then $maxpts
doesn't change after the multiplication.
Paul.