for review: big ints

Bert Thompson aet at hydra.cs.mu.oz.au
Mon Apr 6 23:17:58 AEST 1998


Fergus Henderson <fjh at cs.mu.OZ.AU> writes:

Thanks for the excellent suggestions. I've followed up on them all,
but I have a few observations...

| > 	% We choose base=10000 since 10000^2+10000 < maxint.
| > 	% XXX: We should check this. 
| > :- func base = int.
| > base = 10000.

|Choosing base=16384 would also have the property, and would be
|more efficient.

Yes, I know. I deliberately didn't do this since it meant more
implementation time (not much, admittedly) for not a huge efficiency
improvement.

In short, the bang for buck test failed.

|The last call to error/1 could be avoided by using a disjunction
|rather than an if-then-else:

| 	( CCs = [],
| 		...
| 		
| 	; CCs = [C|Cs],
|		...
|	).

This is a good general rule. Unfortunately, however, there are
cases where if-then-else must be used instead because the mode
system can't infer a tight enough mode. (add_pairs and diff_pairs,
for example.)

|The recursive call for negative numbers means that it allows
|strings of the form "-------42", which is probably not a good idea.

This was a deliberate decision. Apart from aesthetic reasons, why do
you think this not a good idea?

You also mentioned it would be worthwhile to include bit operations
on the integers. I assume you want us to treat the integers as
though they were 2's complement bit arrays. This is not particularly
hard to do, especially if we use base 2^14 as you suggested. However
I probably should let it go till some later date.

Bert



More information about the developers mailing list