<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
I hear Hendrik proposing that "LONGINT" is the name for fixed arbitrary precision integers.<BR>
That it might even have a name. Or the user has to mention it in order to acknowledge<BR>
he is using something potentially inefficient.<BR>
<BR>
<BR>
FileSize = BITS 64 FOR LONGINT;<BR>
FileSize = [1..LongInt.LShift(1, 63)];<BR>
FileSize = LONGINT[64];<BR>
or such <BR>
<BR>
This is not a bad idea.<BR>
<BR>
I think the "real" problem here is a multitude of options/scenarios and<BR>
a lack of vocabulary.<BR>
As I said, there is a time/place for "silent wraparound", for trapping overflow,<BR>
for extending precision to fit.<BR>
<BR>
Also I'm surprised you can't mix REAL and LONGREAL.<BR>
<BR>
Also I don't think INTEGER + LONGINT is all that confusing or, as I said, subtle.<BR>
It isn't /immediately/ obvious how to deal with MIN, MAX, MOD, DIV, but<BR>
it is still not that tricky.<BR>
<BR>
MIN(INTEGER, LONGINT) is INTEGER. Not that difficult to figure out why.<BR>
At least one of the inputs fits in an integer and the result is the smaller input.<BR>
<BR>
MAX(INTEGER, LONGINT) is LONGINT, ditto.<BR>
One of the inputs might not fit in an INTEGER and the result is the larger input.<BR>
<BR>
INTEGER DIV LONGINT is INTEGER<BR>
BIG DIV SMALL1 is SMALL2<BR>
SMALL DIV BIG is 0 remainder SMALL.<BR>
<BR>
LONGINT DIV INTEGER is LONGINT<BR>
Prove with one simple case:<BR>
BIG1 DIV 2 is BIG2.<BR>
Easier BIG1 DIV 1 is BIG1.<BR>
<BR>
Consider: LONGINT MOD INTEGER and INTEGER MOD LONGINT<BR>
SMALL divided by BIG is, again, 0 remainder SMALL, INTEGER<BR>
BIG divided by SMALL1 is SMALL2, remainder [0..SMALL1 - 1] which is INTEGER.<BR>
<BR>
That is, division either gives you 0 and remainder = first number.<BR>
Or it gives you non-zero and remainder is less than the second number.<BR>
50 divided by 100 is 0 remainder 50.<BR>
109 divided by 10 is 10 remainder 9<BR>
<BR>
FOR loops also should allow mixing.<BR>
<BR>
- Jay<BR><BR> <BR>> Date: Fri, 8 Jan 2010 20:44:37 -0500<BR>> From: hendrik@topoi.pooq.com<BR>> To: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] Unbounded but finite LONGINT (was: Re: Integers<BR>> <BR>> On Fri, Jan 08, 2010 at 08:33:42PM -0500, hendrik@topoi.pooq.com wrote:<BR>> > On Fri, Jan 08, 2010 at 07:53:07PM -0500, Tony Hosking wrote:<BR>> > > I think what you are advocating is Rodney's proposal + assignability <BR>> > > of INTEGER and LONGINT + mixed arithmetic.<BR>> > <BR>> > I thought Rodney's propsal still had the compiler impose a bound on the <BR>> > size of LONGINT. Or did I miss something?<BR>> <BR>> In particular, I would have there be no FIRST(LONGINT) or LAST(LONGINT).<BR>> <BR>> -- hendrik<BR>> > <BR>> > I'm proposing to let the programmer use subranges of LONGINT that are as <BR>> > long as he wishes. And if the computer runs out of virtual memory to <BR>> > store one of the programmer's long integers, well, that's the computer <BR>> > imposing the limit, not the language.<BR> </body>
</html>