Discussion:
MoneyADT: Comparison of Infinity value
(too old to reply)
s54zhang
2010-05-22 22:10:18 UTC
Permalink
When dividing a money by zero. The sample code returns $I.nf (infinity i
assume)

Since this 'infinity' value is described in the implementation. Then
what is the behaviour of each of member functions and comparison
functions with respect to 'infinity' Money?

Thanks

ShaoYu Zhang
s54zhang
2010-05-22 22:20:42 UTC
Permalink
Post by s54zhang
When dividing a money by zero. The sample code returns $I.nf (infinity i
assume)
Since this 'infinity' value is described in the implementation. Then
what is the behaviour of each of member functions and comparison
functions with respect to 'infinity' Money?
Thanks
ShaoYu Zhang
I realize that we can never technically use an 'infinity' value money.
This is because we cannot construct an Money object that has 'infinity'
with the command line, and the 'infinity' value created (division by
zero) is immediately discarded.

However, I still feel an object (even one with improper value) should be
used for further operations.
Joanne Atlee
2010-05-23 15:18:05 UTC
Permalink
Post by s54zhang
Post by s54zhang
When dividing a money by zero. The sample code returns $I.nf (infinity i
assume)
Since this 'infinity' value is described in the implementation. Then
what is the behaviour of each of member functions and comparison
functions with respect to 'infinity' Money?
Thanks
ShaoYu Zhang
I realize that we can never technically use an 'infinity' value money.
This is because we cannot construct an Money object that has 'infinity'
with the command line, and the 'infinity' value created (division by
zero) is immediately discarded.
However, I still feel an object (even one with improper value) should be
used for further operations.
Don't worry about division by zero. We should have implemented our
solution to abort (i.e., exit(1)) given that case.

Jo

P.S. It depends on the application, but it is not always the case that
an object with an improper value should be used for further operations.
Loading...