Class provides simple mathematical operations with integers of any size.Integers are processed as strings using old-style schoolbook math.
Download class and sample project
The class provides the following functions:
Returns integer division. If the result is negative, the smaller absolute value will be returned.
Returns the remainder of integer division. If the result is negative, the remainder to the smaller absolute value will be returned. Is called Modus because Mod is a reserved word in REALbasic.
Comment on the compare-functions. If any of the strings are not valid, false will be returned.
If you try to process strings, which contain non-numeric values, an error-string will be returned. You can prevent this by testing your string against the IsValid function before calling any other function.
New 1.0.1: Checks also for leading zeros. A number with leading zeros is not valid. If you are not sure that the number does not have leading zeros, you may use the Strip0 function to clean up your number string.
Cuts leading zeros in a number string.
Parses the string and returns a valid number string, eliminating all offending characters.
If you try to divide by zero (using the Div or the Modus function), an error-string will be returned. You can prevent this by testing your string against the IsNotNull function before calling Div or Modus. IsNotNull also tests for IsValid.
Returns an about-string of the class
Returns the current version of the class
This class does not have any property. Providing it as a class however frees you of problems of namespace in your application. If you need to access to it from the whole program, make it a property of your app-subclass.
This class uses old schoolbook methods, so don't ask for speed. For the moment, I just wanted to make it possible. The sample application shows the ticks used for a calculation in a static texfield.
You may experience the following durations
- Abs: 0.005*lg(a)*c
- Greater, Equal, Lower: 0.01*(lg(a)+lg(b))*c
- Plus, Minus: 0.02*(lg(a)+lg(b))*c
- Mult: 0.01*(lg(a)+lg(b))^2*c
- Div, Modus: (0.02*(lg(a)+lg(b))+0.008*(lg(a)-lg(b)*(lg(b))*c
where c is a constant depending of your processor speed.Divide/Modus are the longest ones and their durations is the less predictable as it depends on the evolution of the reminders.
© Belle Nuit Montage / Matthias Bürcher November 2000. All rights reserved. Written in Switzerland.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Comments please to email@example.com
The latest version is available at http//www.belle-nuit.com/
3.11.00 Released 1.0.1: Stronger checking of number (leading zeros not allowed) both in the XLcalc class as in the Integerfield class. Prevents error when calculating with numbers which have leading zeros.
8.6.00 Released as open source
23.3.00 Release Class XLcalc 1.0.0 and application XLcalculator 1.0.0