-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
146: Implement the 'as32Bit[Un]signedValue' primitives. r=vext01 a=ltratt Java SOM crashes on big integers, so I have defined what I believe to be appropriate semantics for them which appears to be not to perform sign extension in the conversion. For example: ``` ((1 << 60) - 1) as32BitUnsignedValue ``` in Java SOM returns 4294967295, which is bigger than a signed 32 bit can represent. This commit preserves that behaviour. Co-authored-by: Laurence Tratt <[email protected]>
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
" | ||
VM: | ||
status: success | ||
stdout: | ||
0 | ||
1 | ||
4294967295 | ||
4294967295 | ||
0 | ||
4294967295 | ||
0 | ||
4294967295 | ||
0 | ||
1 | ||
-1 | ||
-1 | ||
0 | ||
-1 | ||
0 | ||
-1 | ||
" | ||
|
||
to32bits = ( | ||
run = ( | ||
0 as32BitUnsignedValue println. | ||
1 as32BitUnsignedValue println. | ||
-1 as32BitUnsignedValue println. | ||
4294967295 as32BitUnsignedValue println. | ||
(1 << 60) as32BitUnsignedValue println. | ||
((1 << 60) - 1) as32BitUnsignedValue println. | ||
(1 << 200) as32BitUnsignedValue println. | ||
((1 << 200) - 1) as32BitUnsignedValue println. | ||
|
||
0 as32BitSignedValue println. | ||
1 as32BitSignedValue println. | ||
-1 as32BitSignedValue println. | ||
4294967295 as32BitSignedValue println. | ||
(1 << 60) as32BitSignedValue println. | ||
((1 << 60) - 1) as32BitSignedValue println. | ||
(1 << 200) as32BitSignedValue println. | ||
((1 << 200) - 1) as32BitSignedValue println. | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters