Word32.word -> Int32.int

Stephen Weeks MLton@sourcelight.com
Mon, 28 May 2001 14:09:26 -0700

> What,  if  any, is the official way to convert a Word32.word to an Int32.int,
> with the result being negative it the most significant bit of the argument is
> set?   I  know that in MLton I can just do Word32.toIntX because int's are 32
> bits.  I know that in SML/NJ I can use Word32.toLargeIntX, but MLton  defines
> LargeInt to be IntInf.  I like this, but this forces me to go to IntInf.int's
> when there clearly is no need for it.
> Is there any portable solution that isn't going to be very slow?

I don't know of one.  I gave up on trying to write such things portably a long
time ago.  My current approach is to have a wrapper for the SML/NJ basis (and
any other SML other than MLton that I might use) that makes its basis look like
MLton in terms of unspecified things like word and integer sizes.  Then I write
the code so it is fast in MLton, but I can still debug in SML/NJ.