+ then "-0x" ^ Word32.fmt StringCvt.HEX (Word32.~(w))
+ else "0x" ^ Word32.fmt StringCvt.HEX w
+
+ fun toInt32 w = Int32.fromLarge (Word32.toLargeInt w)
+ fun fromInt32 i = Word32.fromLargeInt (Int32.toLarge i)
+
+ fun abs w = if neg w then Word32.~ (w) else w
+ fun adiv (a,b) = fromInt32 (Int32.div (toInt32 a, toInt32 b))
+ fun amod (a,b) = fromInt32 (Int32.mod (toInt32 a, if neg a andalso neg b then toInt32 b
+ else if neg b then toInt32 (abs b)
+ else if neg a then toInt32 (Word32.~ b)
+ else toInt32 b))
+
+ fun lt (a,b) = Int32.compare (toInt32 a, toInt32 b) = LESS
+ fun gt (a,b) = Int32.compare (toInt32 a, toInt32 b) = GREATER
+ fun le (a,b) = case Int32.compare (toInt32 a, toInt32 b) of LESS => true | EQUAL => true | _ => false
+ fun ge (a,b) = case Int32.compare (toInt32 a, toInt32 b) of GREATER => true | EQUAL => true | _ => false
+