(Base One logo) .NET database and distributed computing tools

Base One Number Class
Frequently Asked Questions

The Base One Number Class - Overview


Table of Contents

  1. What is the Base/1 Number Class and why it is required?
  2. Which types of applications benefit from the Number Class?
  3. How easy is it to use the Number Class?
  4. Does the Number Class depend on the platform or operating system?
  5. Can the Number Class be used with Microsoft Foundation Classes (MFC)?
  6. What is unique about the technology used in the Base/1 Number Class?
  7. How does the Number Class conserve memory and disk space?
  8. Why is Number Class arithmetic and comparison extremely efficient?
  9. What are the error-handling features of Base One's Number Class?
  10. What about the Microsoft modulo bug?
  11. Why  is  the Number Class well suited to database applications?
  12. Do I need to get the Base/1 Foundation Component Library to use the Base/1 Number Class?
  13. How does the Number Class compare with C++'s built-in numeric types?
  14. How does the Number Class compare with Currency data types?
  15. How does the Number Class compare with Binary Coded Decimal (BCD)?
  16. How does the Number Class compare with Rogue Wave's Money.h++?

What is the Base/1 Number Class and why it is required?

The Base/1 Number Class is a software product that enables you to improve the accuracy of arithmetic in any C++ application.  While C++ has become the tool of choice for building all types of applications, it still suffers from limitations that can be traced to its roots as a scientific programming language for minicomputers.  For example, C++ lacks features supporting high-precision decimal arithmetic, which have long existed on mainframe computers because of their orientation toward large-scale business applications.  Base One's Number Class fills this gap, bringing the power and convenience of mainframe computing to C++ programmers.

Although C/C++'s native numeric data types, Int, Double, Float, Long, etc. work fine in many situations, their underlying binary representation and limited precision present problems that become more apparent as the number of significant digits increases.  Thus for example one loses accuracy because of rounding, or worse, results can be grossly in error because of failure to detect the truncation of high-order digits in a calculation that produces an overflow.

While these shortcomings of C/C++ can be overcome with extra programming effort, one must be diligent, and it's easy to make subtle mistakes that don't show up for years.  But the beauty of C++ is that it allows you to solve a problem once and reuse that solution from then on.  That's exactly what we've done in the Base/1 Number Class, which includes fully documented ANSI/C++ source code and everything you need to write more accurate programs on any platform.

Back to Top

Which types of applications benefit from the Number Class?

Because it addresses such a fundamental and general language feature, the Base/1 Number Class applies to a wide range of application types:

The most compelling candidates for the Number Class share one or more of these requirements:

Consider, for example, how some typical applications might be driven to need the additional accuracy afforded by Base One's Number Class.

A currency trading system has been working fine for years, and the company that uses it is growing successfully.  Suddenly they cross a threshold, where the cash balance of an account (in Japanese Yen) reaches too large a value to display in an important report.  They fix the report, but other errors start to crop up and getting accounts to balance is becoming a programming headache.  Unexpected delays and embarrassing complaints from customers grow more frequent.  Eventually, the problem spreads from isolated reports to deeper troubles in core analysis programs and database structures.  Then the whole system goes down, and the MIS department says it's going to require a major rewrite.  The problem they've come up against can no longer be fixed by simple localized adjustments, and it all boils down to the inherent inaccuracy of working with decimal fractions as binary numbers.

An engineering firm is developing a new generation of laser-based telemetry product, which depends on extremely precise measurements of minute differences between large numbers.  Thanks to a breakthrough in their research, they've come up with a way of increasing the accuracy of their device by several orders of magnitude.   They've invested years of programming developing a fast, computationally intensive program that could be logically extended to cope with greater precision.  But while the basic algorithm is still sound, the current program design uses standard C++ double precision floating point numbers, and there's no room to store the extra digits they will need to the right of the decimal point.  Now they face the prospect of a total rewrite in order to switch to a different representation of numbers throughout their program, and they are concerned that their product's reputation for speed will suffer in the process.

In each of these scenarios the Base/1 Number Class may be the best solution, because it supports increased accuracy efficiently and with minimal programming.

Back to Top

How easy is it to use the Number Class?

Whether you're creating a new application or converting an existing one, using the Base/1 Number Class is about as easy as you could ask.  All that's required is to include the Number Class header file and declare your number variables as instances of the Number Class instead of using C++ native data types like Int, Float, Double, Long, etc.  Through its use of overloaded operators the Number Class provides the same convenience as C++'s built-in data types.  This means that no reprogramming is necessary for all of your existing code that works with numbers, performing arithmetic operations, passing arguments, doing assignments, etc.

By default the Base/1 Number Class assumes a precision and scale (38, 8) sufficient to handle the largest DBMS-supported numeric fields.  This is more than enough to handle the 16-digit limit of C++'s double data type, so you can make a direct substitution without any further programming changes.  That gives you 8 digits to the right of the decimal point and 30 (38 - 8) digits to the left of decimal point, which is ample for most purposes.   If you need to get this much accuracy out of C++ you're out of luck, but with the Base/1 Number Class you can simply adjust the declaration to allow up to 100 significant digits, placing the decimal point at any desired position.

Even if you don't need that kind of precision, Base One's Number Class makes it easier to write reliable applications by adding convenient error-trapping features.  This covers errors like Overflow, Divide by zero, Invalid sign, etc., which are not handled automatically by C++. (For more, see Sample Number Class Usage)

Back to Top

Does the Number Class depend on the platform or operating system?

No.  The Base/1 Number Class is independent of all platforms and operating systems because it is written in ANSI standard C++ and uses the Standard Template Library (STL).  It can be used in various environments like DOS, Windows, UNIX, LINUX, etc., all of which have a standard ANSI/C++ compiler. However, we test only on Win32 platforms, with MS Visual C++, and supply only those makefiles. We've been careful to use only the most basic C++ features and the standard, public STL interface. In addition, we have upgraded the source code whenever developers have reported minor compilation errors when working with non Microsoft compilers. This means that you can develop portable, cross-platform applications using Base One's Number Class. 

Back to Top


Can the Number Class be used with Microsoft Foundation Classes (MFC)?

Yes.  The Base/1 Number Class is compatible with both the Microsoft Foundation Classes (MFC) and the Standard Template Library (STL).  You can use the Base/1 Number Class whether you write Windows/MFC programs with Microsoft's Visual C++ or you program for an STL environment like Unix, using ANSI/C++.  The sample code that ships with the product includes MFC and STL based projects, which both execute the same examples of Number Class usage. (With the Number Class source code, we supply a small string class, clsStrPlus, as a layer between the Number Class and raw MFC and STL strings, and this string class can be easily adapted to handle any peculiarities of the particular STL implementation being used.) 

Back to Top

What is unique about the technology used in the Base/1 Number Class?

The Base/1 Number Class uses an innovative variable-length encoding of numbers that bears some resemblance to Binary Coded Decimal (BCD), but is considerably more efficient in several respects.  One of the keys to Base One's unique patented design is its use of fast, robust STL/MFC string classes to maintain the internal representation of numbers.   This design makes possible a number of features not found in other numeric encoding technologies:

Since we provide the full source code with extensive comments, documentation, and examples, you can learn as much as you want to about our approach.  Students of Computer Science who are interested in data structures and algorithms can greatly benefit from the Base/1 Number Class because few, if any, books on the market cover precision arithmetic in such detail.

Back to Top

How does the Number Class conserve memory and disk space?

Several points about the design of the Base/1 Number Class contribute to its ability to precisely represent very large and very small numbers in a minimum amount of space:

compact representation packs two decimal digits into each byte
If one were to simply store long numbers as character strings, it would take about twice as much space.  Binary Coded Decimal (BCD)/Packed Decimal representations, such as those used on mainframe computers also can store two decimal digits per byte, but Base One's unique patented encoding offers numerous advantages.
variable length encoding stores only the actual digits required
Any fixed-length encoding suffers from the drawback of wasting space, because each variable must be large enough to hold the maximum size and precision its value can attain.  The Base/1 Number Class allocates and stores only the digits that are required to exactly represent the particular value it holds, without needless padding.  When there is a mix of long and short numbers, as is typical in many applications, use of Base One's Number Class substantially reduces memory and disk space requirements.
the length and decimal point are not stored explicitly
No extra space is required to store either the number's length or its decimal point in the Number Class.
unique compression logic further reduces storage requirements
The Base/1 Number Class not only avoids needless padding with leading and trailing zeroes (in numbers like 00123 and .345000), but it also has a unique ability to compress significant zeroes (as in 10000 and .000006).  Thus Number Class shares the advantage of floating point's compact representation of very large and very small numbers, but without the drawback of floating point's limited accuracy.
"Reference Counting" eliminates redundant memory allocations
Because the Number Class uses STL/MFC string classes for its internal representation of numbers, it automatically inherits the benefits of Reference Counting.  This feature, which doesn't pertain to C++ numbers, allows multiple variables to share the same memory if all the variables hold the same number value.  The result is that wasteful memory allocations are avoided in performing assignment statements, passing arguments by value, and obtaining function return values.
Back to Top

Why is Number Class arithmetic and comparison extremely efficient?

Besides simply saving space, the compactness of Base One's Number Class representation provides a performance boost by shortening in-memory data transfers and reducing the amount of disk I/O.  But there are additional reasons for significant speedups owing to the unique design of the Base/1 Number Class:

all arithmetic calculations are performed taking two digits at a time
Base One's algorithms for operations like addition, subtraction, multiplication, division, remainder, quotient, modulus, etc. have been designed to process digits in a pairwise fashion.  On the other hand, Binary Coded Decimal (BCD), which also packs two digits into each byte, requires twice as much work to extract and process each digit individually.
extremely fast numeric comparison logic because no normalization is required
A remarkable feature of the Base/1 Number Class is that it uses highly efficient byte string operations (exactly like strcmp) to directly compare any pair of numbers.  Even if the numbers differ in sign, length, or scale, there is no need for the usual "normalization" step to precede comparison or arithmetic operations.  Other numeric encodings (such as BCD) require additional processing, digit by digit, to put both numbers into a common intermediate representation before their values can be operated upon.  This distinction makes Base One's Number Class much better suited than other technologies for building high-speed searching and sorting applications.
reduced memory management overhead
The benefits of "Reference Counting" (discussed above), not only mean that less memory is consumed, but also less processing is required for dynamically allocating and freeing memory when Number Class values are copied between variables.  What's more, this memory management logic is implicitly handled by the robust, efficient, underlying STL/MFC string classes.
Back to Top

What are the error-handling features of Base One's Number Class?

C++ provides only minimal facilities for detecting and handling errors that can occur in numeric arithmetic and conversion operations.  This makes it necessary for programmers to take extra steps to be sure that certain errors, such as division by zero and overflow, can not occur.  Otherwise, a program may crash or simply yield incorrect results when one of these exceptional conditions arises.  All too often obscure bugs result from failing to add adequate error checking logic, because this is generally viewed by programmers as an annoying detail.  The Base/1 Number Class provides additional capabilities for detecting and handling errors, so these details don't burden the programmer but they also don't get overlooked:

overflow errors
If you add two conventional C++ numbers and the correct result requires more digits than the variable can hold, C++ doesn't detect the error, as you might have expected if you were accustomed to programming on old mainframe computers.  Instead, C++ simply wraps the value, effectively truncating the most significant digits and producing totally incorrect results without any notification.  Base One's Number Class gives you an easy way to trap and handle these errors, without having to write extra code to explicitly check for overflow on each arithmetic operation.
division by zero
C++ also doesn't detect invalid attempts to divide a number by zero (unless you consider immediately crashing to be a form of error "detection").  This too is a type of error that the Number Class makes easy to trap and handle cleanly, again without a lot of extra code.  The Number Class also detects attempts to raise 0 to a negative power.
conversion errors
Another important category of errors is those that can occur when converting back and forth between different types of numeric and character representations.  The limited error-handling features of C++'s conversion functions are greatly improved upon in the Base/1 Number Class.  For example, Number Class conversions discriminate among many specific error types, such as invalid sign, missing digit, negative number converted to an unsigned data type, particular flavors of overflow, etc.   You also have the choice of detecting errors either based on a return code or by raising an exception for which you can supply your own handler.
Back to Top

What about the Microsoft modulo bug?

Over the years of testing of the Number Class, we've discovered nasty bugs in Microsoft's fmod() function, which you can easily confirm for yourself. For example, using the Windows 95 Calculator accessory (evidently built on the same fmod function) try this simple calculation:

5.5 mod 1.1

Instead of giving the correct result, which should be 0, it shows the result as 1.1.  Similar errors are not hard to find, e.g. try 5.1 mod 1.7, 49 mod 9.8, 21.9 mod 7.3, and 36 mod 7.2.  Interestingly, this problem occurs only with certain choices of values and the pattern of failures is not trivially discerned, but there are obviously many more cases.  In fact we found it increasingly rare not to encounter such errors with more decimal places.  We were unable to find any reference to this disturbing bug in the Microsoft Knowledge Base.

Considering how much flack Intel took over an even more obscure arithmetic bug in its Pentium processor, one can only wonder how Microsoft ever got away with this one.   Fortunately, the problem seems to have been quietly fixed in Windows 98, but that's not much consolation to those of us who expect our programs to work properly under Windows 95 and early versions of Windows NT 4.0.  In any case, rest assured that the Base/1 Number Class computes the modulo function correctly under any version of Windows.

The modulo bug described above seems to have been fixed in the latest operating systems and service packs from Microsoft. However, here's a new one we discovered in recent testing of the Number Class:

    d1 = 8853.41959899;
    d2 = 2951.13986633;

fmod( d1, d2 ) returns the same value as that of d2 instead of returning zero. In this example, d1 is a perfect multiple of d2 (d1 = d2 * 3). We got this error on Windows NT Service Pack 5 and 6a and Windows 2000 server. For some versions, the bug did NOT appear in the calculator program, but using fmod() ALWAYS produces this bug. The Number Class properly returns the correct remainder of zero.

Back to Top

Why is the Number Class well suited to database applications?

If you build database applications, the Base/1 Number Class provides additional benefits whether you use a standard relational database management system (RDBMS), an object-oriented database, ISAM, or flat files to store your data.  Besides its general compactness and speed, the Number Class addresses the following issues of importance to designers of information storage and retrieval systems:

modern databases can store numbers that are longer than C++ can manipulate
For example, Oracle can support a 38-digit numeric field, but there is no C++ data type that can exactly represent or perform arithmetic against such numbers.  The Base/1 Number Class can handle numbers of far greater length and precision than those supported by any major DBMS.
C++ numeric data types don't support the concept of a null number, distinct from zero
In database applications it can be useful to have a way of leaving a numeric field blank, meaning that data is not available, but the value is not necessarily zero.  The ANSI SQL database standard has long provided for NULL values, but this notion is foreign to the C++ programming language.  However, Base One's Number Class does support null numbers, as distinct from numbers with a value of zero, so it handles this widely accepted database feature.
conventional number representations are not amenable to efficient indexing
Indexing is essential to good performance in a large database applications, because it greatly speeds up searching and obtaining filtered, sorted query results.  Unfortunately most numeric representations were designed for arithmetic, not for indexing.  Consequently extra logic is needed to transform numbers into keys in a format that collates properly.  None of this logic is handled automatically by C++, so it usually falls upon the DBMS or the application programmer to perform the additional processing.

The Base/1 Number Class has a special internal string format that orders numbers properly under the rules of standard byte string comparison.  In other words, first come blanks, then negative numbers, then zero, and finally progressively increasing positive numbers.  No transformation is necessary for Number Class fields, because they are already in a representation that collates conveniently, making indexing extremely easy and efficient.  Furthermore, Base One's Number Class allows compound keys to be formed simply by concatenating multiple fields, even if they are of mixed character and numeric types.  No other numeric representation has these characteristics.

For users of Base/1 Foundation Component Library (BFC), a further advantage of the Base/1 Number Class is its total integration with BFC's data dictionary and database retrieval and modification operations.  Numbers can be stored into and retrieved from database records directly using Number Class variables.  Also Number Class instances can be initialized to the attributes of a database field defined in the data dictionary, including length (precision), scale, and a formatting mask to be used for display and/or data entry.  For example, if you know that a calculated value will end up being stored in a particular field, initializing the number with that field's name will automatically insure that its length and scale will be the basis for proper rounding behavior and for generating overflow error notification when appropriate limits have been exceeded.

Back to Top

Do I need to get the Base/1 Foundation Component Library to use the Base/1 Number Class?

No.  All you need is an ANSI-compatible C++ compiler.  While the Number Class is a component of the Base/1 Foundation Component Library (BFC), the system's modular design allows us to sell it as a separate product.  There is nothing about the Base/1 Number Class that depends on BFC.  If you have BFC, you do not need to buy the Number Class separately, because BFC includes it.

Back to Top

How does the Number Class compare with C++'s built-in numeric types?

Thanks to Base One's design based on operator overloading, using the Number Class is virtually identical to using built-in C++ number types.  The usual arithmetic operators, assignment statements, parameter passing, etc. work with Number Class variables just as they work with standard C++ numbers.  And because of Reference Counting, the overhead of using the Number Class is comparable to that of standard C++ data types, so it can be used freely without having to be conscious that it is a user-defined C++ class.  But the Number Class has significant advantages over native C++ number types due to these fundamental differences:

binary vs decimal floating point representations
It is commonly known that some simple fractions, like 1/3, can not be exactly represented in decimal notation.  Depending on the choice of base, there will always be certain fractions that can only be represented by an infinitely repeating series of digits to the right of the decimal point.  Because C++ number types use an underlying binary representation, most decimal fractions have no exact representation as standard C++ floating point numbers.  For example even the simple decimal number 0.1 (one tenth) translates into the repeating binary fraction, .000110011001100..., ad infinitum.   This means that C++ floating point is incapable of exactly representing most decimal fractions, regardless of the choice of precision.

On the other hand, the Base/1 Number Class uses a compact decimal encoding, so it can exactly represent any decimal fraction up to 100 digits of precision.  Since people are accustomed to dealing with decimal numbers, this is the form in which numbers usually originate, and also the form in which results are reported.  Financial applications are a classic example of the need for exact decimal arithmetic, because large accounts may be required to balance right down to the penny.  By using the Number Class, you eliminate the fundamental inaccuracy of C++'s binary number types.

limits of precision
The most important general determinant of accuracy is the number of significant digits a number can represent, regardless of whether a binary or decimal encoding is used.   For C++ numbers, the limit comes down to a 64 bit maximum that standard C++ number types can occupy.  This translates into a maximum of 19 significant decimal digits for fixed point C++ numbers, or about 16 significant digits for floating point.   (Remember, the C language evolved from minicomputers.)  The Base/1 Number Class supports up to 100 significant decimal digits, so it can be vastly more accurate than any C++ number.  This makes our Number Class a great tool for scientific and mathematical applications that demand extreme precision.

fixed-length vs variable-length encoding
C++ supports native fixed and floating point numeric types that occupy up to 8 bytes (64 bits).  Floating point is able to represent a much wider range from tiny fractions to very large numbers, but the tradeoff is a reduction in precision.  In either case, C++ numbers use a fixed-length encoding, so that a variable of a declared number type will always be the same size, which must be large enough to hold the largest possible value this type can represent.
 
The Base/1 Number Class, however, is a variable-length numeric encoding built upon standard C++ null-terminated string classes.  Only the amount of space actually needed to hold the current value is allocated.  A single null byte is all that is required to store the NULL value, and a simple decimal number can be stored in as little as two bytes, while a number with as many as 100 significant decimal digits can be stored in another variable, yet these are both instances of the same ubiquitous Number Class type.  For a typical distribution of decimal number values in a real application, the Number Class' variable length can yield dramatic reductions in the consumption of both memory and disk storage.

error-handling features
The Number Class also adds support for handling errors like overflow and division by zero, which are not handled automatically when you use standard C++ number types.
Back to Top

How does the Number Class compare with Currency data types?

Microsoft provides a data type called "CURRENCY" as part of its OLE (Object Linking & Embedding) technology.  To use it in a C++ application, you need to use MFC, which provides a C++ class called COleCurrency.   (In Visual Basic this number type is called VB Currency.)  COleCurrency behaves like a 64-bit integer with automatic scaling to support 4 digits to the right of the decimal point.  While this is a little more convenient than resorting to manual scaling of C++'s basic integer data type, it still suffers from a number of drawbacks:

The Base/1 Number Class has none of these limitations.  It can be used just like any native C++ number type, and calculations are much less restricted in both precision and scale than those of either C++ or COleCurrency.  A Number Class variable can be used freely with any of the standard C++ number types to perform arithmetic, or both the operands can be of Number Class type (which is not possible with COleCurrency for multiplication and division).

Back to Top

How does the Number Class compare with Binary Coded Decimal (BCD)?

The problem of dealing with numbers that don't fit into 64 bits is not a new one.   For decades programmers of IBM mainframe computers have used variations of Binary Coded Decimal or "packed decimal" numeric encodings to cope with long numbers, supported not only by most mainframe programming languages, but right down to the hardware.  The C/C++ programming language and most modern microprocessors, however, do not support packed decimal arithmetic.

Packed decimal numbers are reasonably compact because they store 2 decimal digits in each 8-bit byte, i.e. 1 digit per 4-bit "nibble", using either a fixed-length or a variable-length encoding.  There is no explicit decimal point, and the rightmost nibble is used to store a sign.  For fixed-length numbers, the scale (i.e. the placement of the decimal point) is determined by a declaration statement in the program.  Variable-length packed decimal stores the total length and scale in the first byte of the number.

The Base/1 Number Class is similar to variable-length packed decimal in that it also stores 2 decimal digits per byte and can represent numbers of varying length and scale.  But Base One's innovative encoding is fundamentally different from packed decimal and other variants of BCD, giving the Number Class several major advantages:

Back to Top

How does the Number Class compare with Rogue Wave's Money.h++?

Rogue Wave used to sell a C++ class library called Money.h++ that also supported extended precision decimal arithmetic. According to Rogue Wave's web site, the ".h++ product line entered into obsolescence effective May 1, 2001". Because Base One's Number Class uses standard C++ arithmetic syntax, it's easy to migrate applications off of Money.h++. 

Both Money.h++ and the Base/1 Number Class have a number of features in common:

However, there are a number of significant differences between Rogue Wave's Money.h++ and Base One's Number Class, due to their entirely different internal representation of numbers. Rogue Wave's approach provides separate fixed and floating decimal point classes in 16 different precisions, with each variation requiring a certain fixed-size allocation. Base One's approach uses a single number class that inherently supports a floating decimal point and variable precision, with no fixed-size minimum allocation. Rogue Wave claims that Money.h++ offers the "convenience of BCD", but the unique properties of Base One's innovative design give our Number Class these important advantages:

The Base/1 Number Class is easier to use and easier to understand than Money.h++
Base One's Number Class gives you the convenience of a single versatile class instead of Money.h++'s proliferation of fixed-precision classes. Money.h++ forces you to treat decimal numbers like character strings, so converting  a program from using standard C++ numbers to using Money.h++ requires replacing every literal number with a quoted string - a major hassle in a large conversion effort. Instead, we use overloaded operators to make the Base/1 Number Class really look like a number, so your code requires minimal changes and program conversion is a breeze. (You only need to use a string when the number represented is outside the range supported by C++ numeric constants, which should never be an issue when converting existing programs.)

When it comes to testing and debugging, there's no substitute for good documentation. Rogue Wave provides little more than basic usage documentation, with no detailed descriptions of Money.h++'s internal design and minimal source code comments to aid the programmer in analyzing and verifying the behavior of its complex underlying algorithms. Even Microsoft sometimes goofs, but you'll have to take it on faith that Money.h++ won't disappoint you.

The algorithms used in Money.h++ are not as simple as those of Base One's Number Class, and by supplying well-commented source code, plenty of examples, plus detailed design documentation, we make understanding the Number Class even simpler. We explain clearly not only the usage, but have devoted a lot of effort to explaining the internal logic in our user manual, so you can convince yourself before depending on the Number Class to handle your critical applications.
 
The Base/1 Number Class makes better use of memory and disk space than Money.h++
Fixed-length encoding schemes such as those in Money.h++ have the drawback that a lot of space typically gets wasted. Each variable must be allocated with a size sufficient to hold the longest possible value it can represent, regardless of the particular value it contains. The compact, variable-length encoding used in the Base/1 Number Class avoids this problem by storing only the digits that truly are required to represent the current value, compressing away both leading and trailing zeroes.
 
The Base/1 Number Class supports unique optimizations not found in any other product
Rogue Wave's Money.h++ can be expected to suffer from some of the same drawbacks shared by Binary Coded Decimal (BCD) encodings, which incur considerable overhead in normalization when performing arithmetic and comparison operations. By contrast, Base One's unique design entirely eliminates the expense of normalization.
 
The Base/1 Number Class is directly collatable for ultra-efficient indexing, unlike Money.h++
A feature that distinguishes the Base/1 Number Class from any other numeric representation that we know of is its collatability. By this we mean the property that Number Class values can be sorted into proper numerical order simply by using high-speed byte string comparison operations directly against our internal representation, even though numbers may be of varying length (precision), scale (placement of decimal point), and sign. Other number types such as those of Money.h++ require a substantial amount of processing to transform values into a representation suitable for efficient sorting and indexing, and still are limited to working with a fixed choice of precision and scale.
 
The Base/1 Number Class handles money arithmetic without being money-specific
Unlike Money.h++, Base One's Number Class is not tied to monetary representations or currency calculations. That's because the main difficulty in handling money can be boiled down to the general problems of high precision decimal arithmetic. For example, scientific applications can be satisfied with a floating decimal point, so long as a fixed precision can be guaranteed. This is not a sufficient form of precision for business and database applications. If the decimal point is allowed to float, then, for example, you can't depend on the accuracy to a particular number of digits to the right of the decimal point. In other words, "accurate to the penny" means knowing that no operation caused the value to the right of the decimal point to be lost through rounding. For this reason Number Class uses a fixed scale that can satisfy both business and scientific applications.

The Number Class is just a small (operating system independent) part of Base One's Foundation Component Library (BFC), which is designed for building business systems with Visual C++ and MFC. If you use BFC, there are other C++ classes available to speed development of financial applications. For example, the Mask Class provides number formatting that handles internationalization issues like currency and the characters for decimal point and thousands separator. (The default characters to be used for currency, decimal point and thousands separator are obtained from Control Panel/Regional Settings, as stored in the Win.ini file). However, the Number Class by itself is all that is needed for the efficient, accurate, decimal arithmetic required for developing sophisticated financial applications.

Even if you already own and use Rogue Wave's products, you'll find the Base/1 Number Class to be an indispensable tool to add to your arsenal, at an unbeatable price.

Back to Top

Number Class Intro | Overview | FAQ | Representation | Algorithms | Sample Usage | Prices


Home Products Consulting Case Studies Order Contents Contact About Us

Copyright © 2012, Base One International Corporation