// File: decimal.hpp // Description: Decimal class // Project: - // Version: 1.00 // Revision: A // Content: Simple decimal class for "Cobol like" numerical manipulations // // // Language: Zortech C++, ver. 3.0 // OS: MS-DOS // Date: 04.04.1997 // Author: Peter Fabo // Mail: fabo@fmph.uniba.sk // Phone: 00421 7 729248 // 00421 7 724000 kl. 516 // 00421 905 615536 // 00421 7 729248 // // Copyright Centaur s.r.o. // MFF UK, Mlynska dolina // 842 15 Bratislava // Slovakia // // The copyright to the computer program(s) herein // is the property of company Centaur s.r.o., Slovakia. // The program(s) may by used and/or copied only with // the written permission of company Centaur s.r.o. // or in accordance with the terms and conditions // stipulated in the agreement/contract under which // the program(s) have been suplied. // // History // Date Who V/R What // 04.04.1997 pf 1.00/A creation // // // // Imlementation Dependencies #ifndef __DECIMAL_HPP_ #define __DECIMAL_HPP_ #include #include #include #include #define DECIMAL_LENGHT 6 // Header data enum decimal_error { DECIMAL_OK, DECIMAL_OVERFLOW, DECIMAL_DIV0 }; class decimal { static long int decimalLenght; // lenght of decimal part static long int decimalMask; // 10^decimalLenght static long int decimalMask_2; // 10^(decimalLenght/2) -> for oper. * long int integerPart; long int decimalPart; int decimalPartLenght(); // internal function for calculating // lenght of dec. part, used for // printing '0' a.e. in 1.00001 etc // void setAccuracy(int); // not implemented // int accuracy; public: decimal(double); // constructors decimal(long int=0); decimal(char *); decimal& operator=(decimal &); decimal& operator-(); decimal& operator +=(decimal &a){ return (*this)+a; } decimal& operator -=(decimal &a){ return (*this)-a; } decimal& operator *=(decimal &a){ return (*this)*a; } decimal& operator /=(decimal &a){ return (*this)/a; } friend decimal operator +(decimal &, decimal &); friend decimal operator -(decimal &, decimal &); friend decimal operator *(decimal &, decimal &); friend decimal operator /(decimal &, decimal &); friend ostream& operator <<(ostream &, decimal &); friend istream& operator >>(istream &, decimal &); // friend int operator < (decimal &, decimal &); // not implemented // friend int operator > (decimal &, decimal &); // friend int operator <= (decimal &, decimal &); // friend int operator >= (decimal &, decimal &); operator double (); }; #endif __DECIMAL_HPP_ // End of header data decimal.hpp