Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to convert number to binary number.
- --Jung--
-
Scratcher
100+ posts
How to convert number to binary number.
How to convert number to binary number.
when green flag clicked
ask [How to convert number to binary number.] and wait
broadcast [answer v]
when I receive [answer v]
say [thank you]
- SansStudios
-
Scratcher
1000+ posts
How to convert number to binary number.
Do you know how binary works, or would you like to learn that too 

- Scratch-Minion
-
Scratcher
1000+ posts
How to convert number to binary number.
Here is an algorithm.
You keep joining the remainder after dividing the number by 2 to the binary number that you build up.
Start with a Number eg. 13
Set BinaryNumber to empty.
Repeat the following until Number = 0
Next digit of answer is remainder after dividing by 2
ie. set BinaryNumber to join (Number mod 2) BinaryNumber
Divide number by 2 and discard any decimal part
ie. Number = floor of (Number / 2)
Example:
Number = 13
BinaryNumber =
BinaryNumber = join (13 mod 2) BinaryNumber = 1
Number = floor of (13 / 2) = 6
BinaryNumber = join (6 mod 2) BinaryNumber = 01 * new digit is always joined to front of Binary Number
Number = floor of (6 / 2) = 3
BinaryNumber = join (3 mod 2) BinaryNumber = 101
Number = floor of (3 / 2) = 1
BinaryNumber = join (1 mod 2) BinaryNumber = 1101
Number = floor of (1 / 2) = 0
or just the math:
2 ) 13 remainder 1 (this line reads: 2 into 13 goes 6 remainder 1)
2) 6 remainder 0 (this line reads: 2 into 6 goes 3 remainder 0)
2) 3 remainder 1 (this line reads: 2 into 3 goes 1 remainder 1)
2) 1 remainder 1 (this line reads: 2 into 1 goes 0 remainder 1)
0
Answer is then read upwards from remainders: 1101
You keep joining the remainder after dividing the number by 2 to the binary number that you build up.
Start with a Number eg. 13
Set BinaryNumber to empty.
Repeat the following until Number = 0
Next digit of answer is remainder after dividing by 2
ie. set BinaryNumber to join (Number mod 2) BinaryNumber
Divide number by 2 and discard any decimal part
ie. Number = floor of (Number / 2)
Example:
Number = 13
BinaryNumber =
BinaryNumber = join (13 mod 2) BinaryNumber = 1
Number = floor of (13 / 2) = 6
BinaryNumber = join (6 mod 2) BinaryNumber = 01 * new digit is always joined to front of Binary Number
Number = floor of (6 / 2) = 3
BinaryNumber = join (3 mod 2) BinaryNumber = 101
Number = floor of (3 / 2) = 1
BinaryNumber = join (1 mod 2) BinaryNumber = 1101
Number = floor of (1 / 2) = 0
or just the math:
2 ) 13 remainder 1 (this line reads: 2 into 13 goes 6 remainder 1)
2) 6 remainder 0 (this line reads: 2 into 6 goes 3 remainder 0)
2) 3 remainder 1 (this line reads: 2 into 3 goes 1 remainder 1)
2) 1 remainder 1 (this line reads: 2 into 1 goes 0 remainder 1)
0
Answer is then read upwards from remainders: 1101
Last edited by Scratch-Minion (May 19, 2021 05:34:07)
- SansStudios
-
Scratcher
1000+ posts
How to convert number to binary number.
Here is an algorithm.
… epic algorithm here
This is a really cool algorithm! I never thought of binary like this before
Thanks for sharing!- --Jung--
-
Scratcher
100+ posts
How to convert number to binary number.
Here is an algorithm.
… epic algorithm here
This is a really cool algorithm! I never thought of binary like this beforeThanks for sharing!
Here is an algorithm.thanks
You keep joining the remainder after dividing the number by 2 to the binary number that you build up.
Start with a Number eg. 13
Set BinaryNumber to empty.
Repeat the following until Number = 0
Next digit of answer is remainder after dividing by 2
ie. set BinaryNumber to join (Number mod 2) BinaryNumber
Divide number by 2 and discard any decimal part
ie. Number = floor of (Number / 2)
Example:
Number = 13
BinaryNumber =
BinaryNumber = join (13 mod 2) BinaryNumber = 1
Number = floor of (13 / 2) = 6
BinaryNumber = join (6 mod 2) BinaryNumber = 01 * new digit is always joined to front of Binary Number
Number = floor of (6 / 2) = 3
BinaryNumber = join (3 mod 2) BinaryNumber = 101
Number = floor of (3 / 2) = 1
BinaryNumber = join (1 mod 2) BinaryNumber = 1101
Number = floor of (1 / 2) = 0
or just the math:
2 ) 13 remainder 1 (this line reads: 2 into 13 goes 6 remainder 1)
2) 6 remainder 0 (this line reads: 2 into 6 goes 3 remainder 0)
2) 3 remainder 1 (this line reads: 2 into 3 goes 1 remainder 1)
2) 1 remainder 1 (this line reads: 2 into 1 goes 0 remainder 1)
0
Answer is then read upwards from remainders: 1101
- QuantumCodes
-
Scratcher
30 posts
How to convert number to binary number.
If you want a scratch algorithm to convert decimal to binary, then this should work :
https://scratch.mit.edu/projects/433010278/editor/
https://scratch.mit.edu/projects/433010278/editor/
- NeverEndingFire_
-
Scratcher
1 post
How to convert number to binary number.
TYSM I COULDN'T FIGURE IT OUT T-T
- Discussion Forums
- » Help with Scripts
-
» How to convert number to binary number.




