<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Ok, I think maybe I should go back to the version where the type carries precision and each function is a small wrapper over TInt where I extend, call TInt, and then checked truncate.<BR>
Or at least call TInt and checked truncate, maybe no need for extend.<BR>
Something like that.<BR>
<BR>
<BR>
That will still leave the hard work in TInt.<BR>
<BR>
<BR>
I had hoped TInt could do "everything" for me.<BR>
It is a little disappointing -- it was for doing "target math", which is what I want, but now it is just for doing 64bit math on any host. Probably should be called Int64..<BR>
<BR>
<BR>
On the other hand, m3back historically just did host INTEGER math, no overflow checks. So maybe ok asis.<BR>
Adding the overflow checks found overflow in user source though, so I think a good thing.<BR>
I'll probably just go back a day or so, as described, where each function in M3BackInt/M3BackWord is about one line. No need for th TInt/TWord changes then, even though they were acceptable.<BR>
<BR>
- Jay<BR><BR> <BR>
<HR id=stopSpelling>
From: hosking@cs.purdue.edu<BR>Date: Thu, 25 Feb 2010 12:20:49 -0500<BR>To: jay.krell@cornell.edu<BR>CC: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] TInt/TWord/m3back<BR><BR><BASE>This all speaks to your trying to use TInt for purposes it was never intended. It is there in support of the compiler front-end not compiler back-ends.
<DIV>
<DIV>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV><SPAN style="FONT-SIZE: medium" class=ecxApple-style-span><FONT class=ecxApple-style-span color=#0000ff face="'Gill Sans'"><BR></FONT></SPAN></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV></SPAN></SPAN></DIV>
<DIV>
<DIV>On 25 Feb 2010, at 08:24, Jay K wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>Tony, it should now be much closer to your intent.<BR> I grant maybe the constants are misplaced, and I should try again to use ToBytes.<BR> <BR> <BR>I'm worried though.<BR>It used to be I could do:<BR> <BR> <BR>TInt.Add(Int{4,FF,FF,FF,7}, One)<BR></DIV></SPAN></BLOCKQUOTE>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>and be told it overflowed, in 4 bytes of precision.<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>You must check explicitly that there is no overflow. This is easy enough.</DIV>
<DIV><BR></DIV>
<DIV>TInt.LT(result, Target.Int32.min) OR TInt.LT(Target.Int32.max, result)</DIV><BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> Now it'll just do it in 8 and no overflow.<BR> <BR> <BR>And chop always succeeds.</DIV></SPAN></BLOCKQUOTE>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> <BR>Maybe:<BR> <BR> <BR>PROCEDURE CheckChop (VAR r: Int; n: CARDINAL) =<BR> BEGIN<BR> IF And (r [n-1], SignMask) = 0<BR> THEN FOR i := n TO LAST(Int) DO IF r [i] # 0 THEN RETURN FALSE END; END;<BR> ELSE FOR i := n TO LAST(Int) DO IF r [i] # Mask THEN RETURN FALSE END; END;<BR> END;<BR> RETURN TRUE;<BR> END CheckChop;<BR><BR>?<BR><BR> - Jay<BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></DIV> </body>
</html>