Why not also leave numbers in binary or hexadecimal form for her?
Can't she convert them to decimal herself?
It goes without saying that the numbers will be returned in binary form
in the scheme I have described. Are you suggesting that the value of
"a+b" (where a and b are rationals) should be a string? By all means
provide utility functions to create string representations in whatever
format you like, but they won't be used until after the users have
finished their calculations, and those calculations will in general be
simpler to program if you use the simpler numerator-denominator
representation.
The needs of the machine and the needs of the human are different.
Not in any essential way, when it comes to calculating with integers.
Have the machine use whatever format is most efficient for its own
work, and have it perhaps convert to another format to show the human.
What's your point? What's wrong with the numerator-denominator format?
That's how I prefer to write fractions when calculating on paper, the
reasons being essentially the same as the reasons that I would use that
format internally in a rational number class.
Why on earth would she care how the computer stores the numbers, as
long as the answers come out right?
The concept of a rational number is defined in terms of a numerator and
denominator. It really is, honest. A rational number is an equivalence
class of ordered pairs (a, b) where a and b are integers, b is nonzero
and (a, b) is defined to be equivalent to (c, d) if and only a*d == b*c.
Anyone who provides me with a rational number class had better assume
I'm going to be interested in obtaining a numerator and denominator from
an instance.
Given two rational number classes I would try, /ceteris paribus/, to
choose the more efficient. If this were independent of the internal
representation then fine, but it isn't.
Do you care what makes the sun
shine, or is it enough to know that it shines and will almost
certainly continue to shine for billions of years?
Sure I care what makes the sun shine. Where's your childlike wonder? If
everyone thought like that we'd all still be in dark ages.