Skip to content

Instantly share code, notes, and snippets.

@ariutti
Created February 19, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariutti/5a9b2fe01448eff49fe3e530d46864da to your computer and use it in GitHub Desktop.
Save ariutti/5a9b2fe01448eff49fe3e530d46864da to your computer and use it in GitHub Desktop.
A Processing sketch to turn a decimal number to its binary rapresentation.
/*
* 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