At 11:05 AM +0200 8/24/04, Leopold Toetsch wrote:
Dan Sugalski <[EMAIL PROTECTED]> wrote:

 I'm up for some discussion on this one. I'm tempted to leave integer
 binary ops integers,

I've already outlined that Python as well as Perl6 silently promote to BigInt. I'd rather have Integer as the common base type that implements most of these two languages' integer type.

And BTW divistion by zero behavior needs to be nailed down too.

And inf handling too.

Okay, here's my thought. Basic PMC operations which result in a division by zero, or operations which'd produce either an infinite or not-a-number result, throw an exception. The default MMD functions for math will do this, and folks who want a different result can override the MMD table. (Which could be made scoped, if we really wanted to, though I'm not sure I do)

This doesn't address the issue of low-level ops with numbers, but we can get there later.

I'm thinking now that multiplication of integers should upgrade to a float (which is large enough to hold the result with no loss of precision), division of integers should return a bignum (or a bigrat), and all float operations should produce floats. The destination PMC type can downconvert if it wants, so:

    Pint = Pint / Pint

would produce a bignum which'd then be converted to an integer as part of the store. (I'm not that tied to the production of a bignum though. Feel free to argue me out of it if you want)

As for rounding, I'm open to changes there too. Standard for computing is round-to-zero, since it's easy (drop the fractional part) but I was always taught round-to-closest-int. Too many physical sciences classes, I expect. Either way's arguably correct, and arguably horribly wrong, so I can see it being a big tossup there.
--
Dan


--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to