Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Twos-complement/Wren/twos-complement-1.wren
Normal file
3
Task/Twos-complement/Wren/twos-complement-1.wren
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var a = 0
|
||||
a = -a
|
||||
System.print(a) // -0
|
||||
8
Task/Twos-complement/Wren/twos-complement-2.wren
Normal file
8
Task/Twos-complement/Wren/twos-complement-2.wren
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var pow32 = 2.pow(32)
|
||||
var pow31 = 2.pow(31)
|
||||
var bs = [-pow31, -pow31+1, -2, -1, 0, 1, 2, pow31-2, pow31-1]
|
||||
for (b in bs) {
|
||||
var b2 = ~b + 1
|
||||
if (b2 > pow31) b2 = b2 - pow32
|
||||
System.print("%(b) -> %(b2)")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue