<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><base href="x-msg://9541/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>
Actually, writing that you get what you expressed:<div><br></div><div><span style="font-family: Times; ">If an explicit base is present, the value of the literal must be less than </span><tt>2^Word.Size</tt><span style="font-family: Times; ">, and its interpretation uses the convention of the </span><a href="http://www.cs.purdue.edu/homes/hosking/m3/reference/word-intf.html" style="font-family: Times; "><tt>Word</tt></a><span style="font-family: Times; "> interface.</span><br><br><div><div>Word.T is unsigned, so you only get the 32 bits you asked for.</div><div><br></div><div>If you want a signed value then you need to express the sign explicitly starting from a constant, just as you have done with:</div><div><br></div><div><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; "><div dir="ltr">CONST UID_WORD = (* 16_97E237E2 *) -1881139893;<br></div></div></blockquote></div><div><br></div><div>On Apr 11, 2013, at 3:14 PM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr"> <span class="Apple-converted-space"> </span><br> I have some 32bit constants. <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br>e.g.: <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> CONST UID_WORD = 16_97E237E2; <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> but this isn't right.<span class="Apple-converted-space"> </span><br> On a 64bit system, that is a 64bit integer<span class="Apple-converted-space"> </span><br> with a "large" positive value, instead of<span class="Apple-converted-space"> </span><br> the intended 32bit negative value.<span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> Is there an ideal (i.e. CONST) way to do this?<span class="Apple-converted-space"> </span><br> Portably to 64bit systems?<span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> I have found two unsatisfactory choices:<span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> 1) use decimal:<span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> #include <stdio.h><span class="Apple-converted-space"> </span><br> int main()<span class="Apple-converted-space"> </span><br> {<span class="Apple-converted-space"> </span><br> printf("%X %d\n", 0x97E237E2);<span class="Apple-converted-space"> </span><br> return 0;<span class="Apple-converted-space"> </span><br> }<span class="Apple-converted-space"> </span><br> <br> <br> cc 1.c<span class="Apple-converted-space"> </span><br> ./a.out<span class="Apple-converted-space"> </span><br>97E237E2 -1881139893<br><br>CONST UID_WORD = (* 16_97E237E2 *) -1881139893;<br> <br> <br> 2) change it to VAR and a runtime conversion:<br> <br> <br> PROCEDURE SignExtend(a, b: INTEGER): INTEGER =<br> BEGIN<br> b := Word.LeftShift(-1, b - 1);<span class="Apple-converted-space"> </span><br> IF Word.And(a, b) # 0 THEN<span class="Apple-converted-space"> </span><br> a := Word.Or(a, b);<span class="Apple-converted-space"> </span><br> END;<span class="Apple-converted-space"> </span><br> RETURN a;<span class="Apple-converted-space"> </span><br> END SignExtend;<span class="Apple-converted-space"> </span><br><br> PROCEDURE SignExtend32(a: INTEGER): INT32 =<span class="Apple-converted-space"> </span><br> BEGIN<span class="Apple-converted-space"> </span><br> RETURN SignExtend(a, 32);<span class="Apple-converted-space"> </span><br> END SignExtend32;<span class="Apple-converted-space"> </span><br><br> CONST IntegerToTypeid = SignExtend32;<span class="Apple-converted-space"> </span><br><br><br> VAR UID_WORD := IntegerToTypeid(16_97E237E2); (* CARDINAL *)<span class="Apple-converted-space"> </span><br><br>This gives a warning:<br><br>CONST UID_INTEGER : INT32 = 16_195C2A74; (* INTEGER *)<br><br>and then at runtime gives an error assigning it to an INT32.<br><br><br> any other ways?<span class="Apple-converted-space"> </span><br><br><br>Thanks,<br> - Jay<br><br><br></div></div></blockquote></div><br></div><br><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF"><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Antony Hosking</span></span></font></font><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-converted-space"> </span>|<span class="Apple-converted-space"> </span></span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; ">Associate Professor</span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "> | Computer Science | Purdue University</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; ">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-converted-space"> </span>+1 765 427 5484</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><br class="khtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="Apple-interchange-newline"></span></div></span></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></body></html>