Gibbs Tanton writes:
> You might want to try Math::BigFloat instead.
I originally wrote:
> I'm trying to perform the following calculation:
> $value = ($float + $integer) * 100000;
> $string = "$value:test";
I now have code like the following:
use Math::BigFloat;
# Initial values
my $float = 1000123123.12345;
my $integer = 123456789;
my $factor = 1000000;
my $string = ":test";
my $value;
$value = Math::BigFloat->new($float);
print "Value 1: $value.\n";
$value = Math::BigFloat->new($value->fadd($integer));
print "Value 2: $value.\n";
$value = Math::BigFloat->new($value->fmul($factor));
print "Value 3: $value.\n";
$value =~ s/.$//; # Remove decimal point
print "Value 4: $value.\n";
$value .= $string; # Append string
print "Value 5: $value.\n";
This outputs:
Value 1: 1000123123.12345.
Value 2: 1123579912.12345.
Value 3: 1123579912123450..
Value 4: 1123579912123450.
Value 5: 1123579912123450:test.
It seems awful to call Math::BigFloat->new() three times to do the
calculation part. Is there a simpler way of doing this?
+ Richard J. Barbalace
<[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]