for review: big ints

Bert Thompson aet at hydra.cs.mu.oz.au
Sat Apr 4 19:06:42 AEST 1998


Mark Anthony BROWN <dougl at cs.mu.OZ.AU> writes:

| > 
| > Gday peoples,
| > 
| > Could someone please review this addition to the library.
| > 
| > Thanks,
| > Bert

|Sure, but I've only taken a brief look so far.  First comment:

|The data is not stored in a canonical form (eg i(1, []) represents
|the same thing as i(0, [])), and while this is not a problem per se,
|it makes it easy to introduce errors in the implementation.

That's a good point. I should have mentioned precisely what forms
are allowed. (They can not be enforced by the type system, BTW.)
i(0,[]) is allowed. i(1,[]) is not. Any number equal to zero must
have a sign of zero.

|Notably,
|    integer:'>'(abs(integer(0)), integer(0))
|succeeds.

That's a bug in abs. Now fixed.

|From an implementation view, what data are admissible?  big_cmp/2, for
|example, seems to think that i(1, []) is not, but abs/1 thinks it is.

Given that `integer' is an ADT, it is possible to create integers
only using the given `constructors'. This means only valid integers
can be created. Of course, all the implementation predicates must
maintain this validity. (`abs' did not.)

Cheers,
Bert



More information about the developers mailing list