IntInf and word operations

Stephen Weeks sweeks@intertrust.com
Fri, 22 Sep 2000 18:15:02 -0700 (PDT)


> For  Word.fromLargeInt,  then  the meaning seems pretty clear to me.  Here is
> code that will do this, assuming a large int is an IntInf.int:
> 
>     fun fromLargeInt (i: IntInf.int): Word.word =
>            Word.fromInt (IntInf.toInt (IntInf.mod (i, IntInf.<< (1, 32))))
> 
> Well, ok, it would be that if I had written IntInf.<<, but  since  I  didn't,
> you have to use
> 
>     fun fromLargeInt (i: IntInf.int): Word.word =
>            Word.fromInt (IntInf.toInt (IntInf.mod (i, 4294967296)))

This seems wrong due to IntInf.toInt overflowing.  Word.fromLargeInt should
never overflow (at least that's how I read the spec).