Skip to content

Instantly share code, notes, and snippets.

@arakov
Created July 31, 2015 14:26
Show Gist options
  • Save arakov/9effe777bf4de4524ded to your computer and use it in GitHub Desktop.
Save arakov/9effe777bf4de4524ded to your computer and use it in GitHub Desktop.
Binary sample
#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