Usage of the faulty number type

This is a discussion on Usage of the faulty number type within the C++ Programming forums, part of the General Programming Boards category; I have the following problem that is quite complex and don't have a clue how to solve it:
---
Let's ...

Usage of the faulty number type

I have the following problem that is quite complex and don't have a clue how to solve it:

---

Let's assume that we have got a class that defines the new type called FaultyUnsignedLongLong, which is similar to standard unsigned long long, but in which some arithmetic operations on numbers in this type are returning false values or are causing errors.

The problem is to create a function FaultyUnsignedLongLong cprod(const int &fromInt, const int &toInt) that is calculating the product (fromInt)*(fromInt+1)*...*(toInt-1)*(toInt), where fromInt and toInt are integers such that 0 <= fromInt <= toInt <= 600000.

The type FaultyUnsignedLongLong is implementing some arithmetic and logical operators. Unfortunately there is always a risk that these operators will returne false results. Arithmetic operations can cause the following exceptions:

- class ErrorCalculation {}; - operation caused an error and will not return the result,
- class ErrorPrevCalculation {}; - previous arithmetic operation was calculated in the incorrect way, so the result that was returned by this operations has been incorrect,
- class ErrorPrevCalculaionsIncreasedByOne : public ErrorPrevCalculation {}; - means that the previous arithmetic operation returned a result that was larger by one than it's true solution,
- class SystemError {}; - means that operation has cause an overall reset (values of all variables that were defined as FaultyUnsignedLongLong are change to 0). Such reset could be also cause on purpose - you have to use a static method reset().

All of the exceptions can occur in a random manner.

The file in which we are implementing the function FaultyUnsignedLongLong cprod(const int &fromInt, const int &toInt) must have the following properties:

-it should include only the file FaultyUnsignedLongLong.h,
-using #define inside the file is forbidden,
-inside the file one can't use or declare any variables of the type other then FaultyUnsignedLongLong (particullary one can't useconst_cast, type_of, class, struct or any other keywords like bool, char, long, float etc.; the int keyword can be only used twice in the definition of the function FaultyUnsignedLongLong cprod(const int &fromInt, const int &toInt),
-there should be only a definition of one function: FaultyUnsignedLongLong cprod(const int &fromInt, const int &toInt) that is calculating the product (fromInt)*(fromInt+1)*...*(toInt-1)*(toInt),
-each of the variables fromInt, toInt could be used only 4 times in the file.

As to the various properties ..... they're coding constraints. All you need to do is identify some method (eg an algorithm) that will compute the required result, and take recovery action whenever an exception is thrown. Once you have such an algorithm described, implementing it within the coding constraints should be fairly simple.

And, no, I'm not going to show sample code ..... I assume the whole point of the exercise is for you to learn by thinking through and doing it yourself.

If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.