Last active
May 3, 2018 09:38
-
-
Save yowcow/cc8ec530ab063f7a40bf699969378efb to your computer and use it in GitHub Desktop.
Binary/Decimal/Hex in Perl 6
This file contains hidden or 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
use v6; | |
# Hex => Dec | |
:16("ff").base(10); # 255 | |
# Dec => Bin | |
:10("10").base(2); # 1010 | |
# Bin => Hex | |
:2("1111").base(16); # F | |
# Bitwise AND | |
200 +& 13; # 8 | |
:10("200").base(2); # 11001000 | |
:10("13").base(2); # 1101 | |
#----------------------------- | |
# 00001000 | |
:2("00001000").base(10); # 8 | |
# Bitwise OR | |
200 +| 13; # 205 | |
:10("200").base(2); # 11001000 | |
:10("13").base(2); # 1101 | |
#----------------------------- | |
# 11001101 | |
:2("11001101").base(10); # 205 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment