Jeremy Roman
2011-06-25 22:25:37 UTC
The assignment specifies that a rational number should be printed in a
form like "3/4" or "-3/4". It is natural to assume (because the
assignment does not specify) that rational numbers should be read from
an input stream in the same format.
Unfortunately, after implementing this, I discovered that the sample
solution (object file) does *not* accept this format. Is it acceptable
to take rational numbers in the format "3/4", or is there another format
(not given in the assignment) that we should accept, such as "3 4",
which the sample solution seems to parse correctly.
Also, how many edge and error cases are we required to handle? It is
possible to come up with a number of cases which are not representable
(e.g. 1/INT_MAX * 1/2): is it acceptable to have undefined behaviour in
these cases? What about cases where the final result would be
representable, but intermediate values may not be (the assignment does
specify that at least one such case 1/INT_MAX + 1/INT_MAX, should be
handled, but there are numerous others)?
form like "3/4" or "-3/4". It is natural to assume (because the
assignment does not specify) that rational numbers should be read from
an input stream in the same format.
Unfortunately, after implementing this, I discovered that the sample
solution (object file) does *not* accept this format. Is it acceptable
to take rational numbers in the format "3/4", or is there another format
(not given in the assignment) that we should accept, such as "3 4",
which the sample solution seems to parse correctly.
Also, how many edge and error cases are we required to handle? It is
possible to come up with a number of cases which are not representable
(e.g. 1/INT_MAX * 1/2): is it acceptable to have undefined behaviour in
these cases? What about cases where the final result would be
representable, but intermediate values may not be (the assignment does
specify that at least one such case 1/INT_MAX + 1/INT_MAX, should be
handled, but there are numerous others)?
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Jeremy Roman
Student, Computer Science
University of Waterloo