You may download these copyrighted source code files for use in:

For permission to use them in commercial software products, contract development work, or commercial courses, call IDI (773) 736-9661.

Object-Oriented Numeric Class Definitions -- C++ and Java

We're giving away Money!

C++ or Java applications that handle amounts of money need a solid Money class that supports:
  • sufficient range to handle large grand totals
  • sufficient accuracy to satisfy accountants
  • all legitimate arithmetic and comparison operations

For background and details, see Conrad Weisert's paper: "Making C++ Practical for Business Applications", ACM SIGPLAN Notices, December, 1995.

Note that none of C's built-in or primitive data types is satisfactory. A series of articles in the C/C++ Users' Journal addressed conversion of money amounts to external representations, without proposing a practical Money class.

It's a Date

IDI's component library contains a broad range of calendar manipulation and date conversion routines in PL/I, Basic, and Cobol, as well as complete class definitions in C++ and Java. The class definitions support the point-extent pattern for all meaningful operations on combinations of dates and durations. Naturally, all are Year-2000 compliant.

The Java version is available as freeware.

Warning: Never use Java's "standard" Date and Calendar classes in a serious application. They're badly flawed in ways that affect program maintainability and they violate important principles of object-oriented design.

New -- What's your Angle?

Object-oriented programs that calculate with or manipulate plane angles need an Angle class.

  • The Java version is available here as freeware.
  • The C++ version is found in Conrad Weisert's 2005 book

Java Independent Functions

Integer Functions -- a pseudo class containing useful utility functions that perform operations on one or two integers:

  • Convert integer to Roman numerals
  • Convert integer to English
  • Convert integer to string by base
  • Decompose integer into prime factors
  • Greatest common divisor and least common multiple of two integers
  • Others

BASIC functions and subroutines

NOTE: IDI's reusable component library also contains C++, Java, PL/I, and COBOL implementations of many of these routines. Call (773) 736-9661 for information.

Object-Oriented Discrete Classes

C++ Compatibility warning

A peculiarity in character-line representation raises an irritating problem. Each line of source code (ASCII text) is terminated by an end-of-line indicator (represented in C by '\n'). Unfortunately that code is rendered differently on different platforms, specifically:

Ordinarily this makes no difference to a compiler. Both codes are considered "white space" and are ignored, except in one situation. That situation arises when a line ends with the preprocessor continuation flag (\). Several C++ compilers get badly confused when they encounter the unexpected line termination characters following the backslash, and generate lots of irrelevant and misleading error diagnostics.

We consider that a compiler bug, but there's no point in arguing when you're in a hurry to get a clean compile.

The source code in these pages may contain the wrong kind of line-termination sequence for your platform. If so, you may have to edit the files, at least the lines that end in backslash. Using an editor under your platform, you can just remove the line breaks and then put them back in. That will correct the problem.

If you find this too irritating, let us know. IDI may in the future provide a software tool to scan a source-code file and make the necessary changes.

Return to top of freeware page.
Return to IDI home page.

Last modified August 1, 2005