Math::Currency

Math::Currency is an exact currency math with formatting and rounding.
Download

Math::Currency Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • John Peacock
  • Publisher web site:
  • http://search.cpan.org/~jpeacock/Math-Currency-0.46/lib/Math/Currency.pm

Math::Currency Tags


Math::Currency Description

Math::Currency is an exact currency math with formatting and rounding. Math::Currency is an exact currency math with formatting and rounding.SYNOPSIS use Math::Currency qw(Money $LC_MONETARY); $dollar = Math::Currency->new("$12,345.67"); $taxamt = $dollar * 0.28; # this sets the default format for all objects w/o their own format Math::Currency->format('EUR'); $euro = Money(12345.67); $euro_string = Money(12345.67)->bstr(); # or if you already have a Math::Currency object $euro_string = "$euro";Currency math is actually more closely related to integer math than it is to floating point math. Rounding errors on addition and subtraction are not allowed and division/multiplication should never create more accuracy than the original values. All currency values should round to the closest cent or whatever the local equivalent should happen to be.However, repeated mathematical operations on currency values can lead to inaccurate results, if rounding is performed at each intermediate step. In order to preserve appropriate accuracy, the Math::Currency values are stored with an additional two places of accuracy internally and only rounded to the "correct" precision when the value is displayed (either by the default stringification or through the use of as_float or as_int).All common mathematical operations are overloaded, so once you initialize a currency variable, you can treat it like any number and the module will do the right thing. This module is a thin layer over Math::BigFloat which is itself a layer over Math::BigInt. Requirements: · Perl


Math::Currency Related Software