IntInf and word operations
Henry Cejtin
henry@sourcelight.com
Fri, 22 Sep 2000 19:56:35 -0500
Are you talking about the bit-wise operation stuff?
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)))
The point is that you think of the bits for negative numbers as being what
they are for 2's complement. I.e., to negate, you complement all the bits
(an infinite number of them) and then increment.