Math::Units::PhysicalValue

Math::Units::PhysicalValue is an object oriented interface for handling values with units.
Download

Math::Units::PhysicalValue Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jettero Heller
  • Publisher web site:
  • http://search.cpan.org/~jettero/Statistics-Basic-0.42/Basic.pm

Math::Units::PhysicalValue Tags


Math::Units::PhysicalValue Description

Math::Units::PhysicalValue is an object oriented interface for handling values with units. Math::Units::PhysicalValue is an object oriented interface for handling values with units.SYNOPSIS use Math::Units::PhysicalValue; my $exit = new Math::Units::PhysicalValue "10,000 ft"; my $open = "3500 ft"; my $delay = "43 s"; my $dist = $exit - $open; my $rate = $dist / $delay; my $weight = "180 lbs"; my $momentum = ($weight * ( ($exit - $open) / $delay )) + "0 kg*m/s"; print "$momentumn"; # prints 3,761.82 kg*m/s print ($rate + "0 miles/hour"), "n" # prints 103.07 miles/hourIn more detail than the synopsis, Math::Units::PhysicalValue (aka PV) keeps track of the units on values that might work in the real world. It splits and stores the value and units separately as an array.Using operator overloading, you can use them how you'd normally use any numeric value. There are probably more gotchas than I can enumerate, but you should be able to stay out of trouble if you keep string values on the right hand side of operators. my $example1 = new Math::Units::PhysicalValue "10,000 ft"; my $example2 = "3500 ft"; my $example3 = "1000 ft"; print ($example1 + $example2 + $example3), "n"; # prints: 13,500 ft print ($example3 + $example2 + $example1), "n"; # generates an error...Perl is smart enough to do $example1 and $example2 in any order, but $example3 + $example2 is evaluated as the number 4500 (with no units) before it gets added to $example1 -- where the units won't match!Requirements:· Perl Requirements: · Perl


Math::Units::PhysicalValue Related Software