Created
February 19, 2018 13:41
-
-
Save ariutti/5a9b2fe01448eff49fe3e530d46864da to your computer and use it in GitHub Desktop.
A Processing sketch to turn a decimal number to its binary rapresentation.
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
/* | |
* A Processing sketch to turn a decimal number to its | |
* binary rapresentation. Pay attention: here | |
* we are printing least significant bits for first. | |
*/ | |
int b = 9; | |
int c = 0; | |
print("#"); | |
for(int i=0;i<8; i++) | |
{ | |
c = (1<<i); | |
c = b & c; | |
c = (c>>i); | |
//print(c + " "); | |
print(c==1); | |
} | |
println(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment