E
Ethan Furman
Hey all.
My thanks to all who have responded so far with my other questions. It
is much appreciated.
Some background on what I'm doing (a good explanation can be found at
http://www.hazelwood.k12.mo.us/~grichert/sciweb/phys8.htm): When
measuring, there is some uncertainty as to the *exact* value; so, when
doing calculations with these measured numbers, one should not present
an answer that seems more accurate than the source. For addition and
subtraction this means the final answer cannot be more precise than the
least precise input: 5.0 + 21.23 = 26.2 (first number only measured to
the tenths, so answer only good to the tenths); for multiplication and
division this means the answer cannot have more significant digits than
the input with the fewest significant digits: 231 * 0.25 = 58 (0.25
only has two significant digits, so answer only has two significant
digits). Important point -- counting is not subject to precision error.
As I have mentioned before, I am making this Measure class for two
reasons: experience with unit testing, I like playing with numbers, I
am unaware of anything like this having yet been done (okay, three
reasons .
So far, I have the init, add, sub, mul, div, cmp, neg, pos, and abs
done, and I'm ready to tackle floordiv, mod, and divmod... okay, maybe
'ready' is too strong a word -- one of the obstacle's I'm facing is that
I, myself, don't have any real use for this class, so I'm stuck on
deciding how floordiv, mod, and divmod should function. As mentioned
above, counting is precise... so should divmod (a // b, a % b), which
returns the count of times b goes into a, and the remainder, be an exact
number, or should it behave like floor(a / b), and preserve the inherent
inaccury present in the measured value a? Should I have floordiv
preserve inaccuracy, and divmod be exact?
Any and all feedback welcome, particularly from anyone who might
actually use the Measure class.
~Ethan
My thanks to all who have responded so far with my other questions. It
is much appreciated.
Some background on what I'm doing (a good explanation can be found at
http://www.hazelwood.k12.mo.us/~grichert/sciweb/phys8.htm): When
measuring, there is some uncertainty as to the *exact* value; so, when
doing calculations with these measured numbers, one should not present
an answer that seems more accurate than the source. For addition and
subtraction this means the final answer cannot be more precise than the
least precise input: 5.0 + 21.23 = 26.2 (first number only measured to
the tenths, so answer only good to the tenths); for multiplication and
division this means the answer cannot have more significant digits than
the input with the fewest significant digits: 231 * 0.25 = 58 (0.25
only has two significant digits, so answer only has two significant
digits). Important point -- counting is not subject to precision error.
As I have mentioned before, I am making this Measure class for two
reasons: experience with unit testing, I like playing with numbers, I
am unaware of anything like this having yet been done (okay, three
reasons .
So far, I have the init, add, sub, mul, div, cmp, neg, pos, and abs
done, and I'm ready to tackle floordiv, mod, and divmod... okay, maybe
'ready' is too strong a word -- one of the obstacle's I'm facing is that
I, myself, don't have any real use for this class, so I'm stuck on
deciding how floordiv, mod, and divmod should function. As mentioned
above, counting is precise... so should divmod (a // b, a % b), which
returns the count of times b goes into a, and the remainder, be an exact
number, or should it behave like floor(a / b), and preserve the inherent
inaccury present in the measured value a? Should I have floordiv
preserve inaccuracy, and divmod be exact?
Any and all feedback welcome, particularly from anyone who might
actually use the Measure class.
~Ethan