Created
July 31, 2015 14:26
-
-
Save arakov/9effe777bf4de4524ded to your computer and use it in GitHub Desktop.
Binary sample
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
#define system. | |
#define system'math. | |
#define system'routines. | |
#define extensions. | |
// --- Program --- | |
#symbol Program = | |
[ | |
// reading | |
#var aNumber := console write:"Enter the number you want to convert: " readLine:(Integer new). | |
// converting | |
#var aBinaryStr := aNumber toLiteral &base:2. | |
// printing | |
console | |
writeLine:"A binary presentation of the number : ":(aBinaryStr padLeft &char:#48 &length:((aBinaryStr length / 4 + 1) * 4)) | |
writeLine:"Press any key to continue". | |
// waiting for any key | |
console readChar. | |
]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment