Last active
September 7, 2021 20:57
-
-
Save Swivelgames/9c625dc266909f7dacdf5d42ca109505 to your computer and use it in GitHub Desktop.
Convert Base-10 Number to 8-bit Binary
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
Base-10 Number: 33 | |
/* (Divide by each number, then multiply by the remainder to the next column's number) */ | |
Value Column ┆128━━━┓ ┆ 64 ┆32 ┆16 ┆8 ┆4 ┆2 ┆1 ┆ | |
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ ┆┄┄┄┄┄┄┃┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆ | |
Current Number ┆33 ┃ ┏▶.2578125 * 128 ┏▶.515625 * 64 ┏▶.03125 * 32 ┏▶.0625 * 16 ┏━━▶.125 * 8 ┏━━▶.250 * 4 ┏━━▶.500 * 2 ┆ | |
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ ┆ ▼ ┃ ┆ ▼━━━━━━━━━┛ ┃ ┆ ▼━━━━━━━━┛ ┃ ┆▼━━━━━━━━┛ ┃ ┆▼━━━━━━┛ ┃ ┆▼━━━━━┛ ┃ ┆▼━━━━━━┛ ┃ ┆▼━━━━━━┛ ┆ | |
Divide ┆33 / 128 ┃ ┆33 / 64 ┃ ┆33 / 32 ┃ ┆1 / 16 ┃ ┆1 / 8 ┃ ┆1 / 4 ┃ ┆1 / 2 ┃ ┆1 / 1 ┆ | |
Carry Remainder ┆0 .2578125 ▷┛ ┆0 .515625 ▷━━┛ ┆1 .03125 ▷━━━┛ ┆0 .0625 ▷━━━┛ ┆0 .125 ▷━━━┛ ┆0 .250 ▷━━━┛ ┆0 .500 ▷━━━┛ ┆1 .000 ┆ | |
Store Quotient Int ┆▼ ┆▼ ┆▼ ┆▼ ┆▼ ┆▼ ┆▼ ┆▼ ┆ | |
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ ┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┆ | |
Stored Int ┆0 ┆0 ┆1 ┆0 ┆0 ┆0 ┆0 ┆1 ┆ | |
/* | |
> 33 / 128 | |
0.2578125 | |
> (128 * 0.2578125) / 64 | |
0.515625 | |
> (64 * 0.515625) / 32 | |
1.03125 | |
> (32 * 0.03125) / 16 | |
0.0625 | |
> (16 * 0.0625) / 8 | |
0.125 | |
> (8 * 0.125) / 4 | |
0.25 | |
> (4 * 0.25) / 2 | |
0.5 | |
> (2 * 0.5) / 1 | |
1 | |
> 0b00100001 | |
33 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment