On Thursday, March 13, 2003, at 12:22 PM, Nathan Bubna wrote:
These aren't bad rules, and I'd considered them also, but they're not what I
meant. I meant that if any operation results in a mathematical whole
number, we ought to return an Integer (or Long if necessary). If any
operation results in a value that is not a whole number, we ought to return
a Double.
How would you test wholeness? Would you test after each operation, or after the entire expression tree is evaluated? What about performance?
i think in the templates numbers should just be
numbers and they should Just Work (tm). given that, i think whole number
results should be returned as whole numbers (Integer) and so on.
Well, then there is an alternative: Use Double arithmetic throughout, and convert Doubles to their decimal representation using the minimum quantity of digits needed to make the round-trip conversion idempotent. This is what ecvt() does in C. To put it differently, operate on doubles, but instead of calling toString() when instantiating the references, call something else that makes 2.0 appear as "2" and 2.4999999995 appear as "3.5" and so forth.
Easy, simple, no run-time penalties on expressions.
Mat�as.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
