Article Preview
Buy Now
| PDF: |
Review
MPCalc Plugin
Issue: 1.1 (August/September 2002)
Author: Jim Rodovich
Article Description: No description available.
Article Length (in bytes): 3,712
Starting Page Number: 9
RBD Number: 1021
Resource File(s): None
Related Link(s): None
Known Limitations: None
Full text of article...
Chances are if you need to do some math calculations with REALbasic, doubles can hold numbers as large or small as you'll require. However, if you need to get very precise answers, in some cases a double might not be sufficient. Typically, numbers represented by doubles are accurate for about the first sixteen digits. Anything to the right of the sixteenth digit is most likely inaccurate. This means that if you're using a double to store a number that's in excess of one quadrillion, you can expect any values after the decimal point to be incorrect.
Fortunately, you won't need to forsake modern technology and resort to using paper and a pencil when you're dealing with highly precise numbers. Instead, you can use MPCalc, a freeware REALbasic plugin that can perform calculations on numbers with up to thirty thousand digits. You can even set the precision yourself, so if you just need twenty digits, your program won't be chugging along calculating 29,980 unnecessary digits.
The MPCalc plugin operates using what is known as the Reverse Polish Notation (RPN). This is somewhat different from what you're probably used to, but it's a small adjustment. In an expression written in RPN, both numbers are written before the operator. For example, instead of writing 1 + 2, you would write 1 2 + in RPN. It's a different way of thinking, but with a little practice, even expressions with several operations are easy to state in RPN.
Unfortunately, instructing MPCalc to execute various calculations isn't quite as simple as performing arithmetic on integers or doubles in REALbasic is. Instead, you'll need to enter a few simple commands to tell the plugin to do anything. Adding two numbers requires five commands: two to enter the first number, one to enter the second number, another to tell MPCalc to add the numbers, and a fifth to read the result. Even though it takes five lines of code to perform such a simple calculation, it's still very easy to issue commands. This is in part due to the simple method names that are easy to remember.
MPCalc gives programmers access to a wide array of mathematical functions. It supports basic arithmetic operations, as well as exponential, trigonometric, hyperbolic, and logarithmic functions. It also supports several more obscure functions, including the Beta and Gamma functions, Bessel functions, and Fresnal Integrals.
Additionally, MPCalc has four storage registers for remembering the results of previous calculations. The registers prove quite valuable since the only other way to store multiple-precision values is by using strings.
Overall, MPCalc is a solid plugin that is fairly well documented. Because of its flexible precision and wide variety of scientific functions, the MPCalc plugin is a worthy addition to your REALbasic toolbox if you do any serious math calculations.
In Brief Product MPCalc Plugin Manufacturer Dr. Robert Delaney Price Free Contact Info delaneyrm-at-mac.com Pros Very high precision, Free Cons Adds about 700k to filesize Rating (1.0 - 5.0): 4.0
End of article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








