decimal-convert
path: /courses/lowLevel/decimal-convert.md
- **fileName**: decimal-convert
- **Created on**: 2024-09-22 17:30:07
file for convert decimal to all units
1- convert decimal to binray
1- convert (15) to binary
- 2 | 15 7 => 1
- 2 | 7 3 => 1
- 2 | 3 1 => 1 2 | 1 0 => 1
- so now when the output for the convert : (1111) get the reminder
numbers from bottom to top so when the divide number / 2 is == 0 then
the convertation finish so in the example when divide 1 / 2 = 0.5 so
when rounded the number it's equl to zero and the float n number
after the . (decimal point) if there then reminder is == 1 if the
number is int number so the reminder is 0 , in end you collect the
reminder from the bottom for 1 to 15 and this the final output
2- convert 20 to binary
- 2 | 20 10 => 0
- 2 | 10 5 => 0
- 2 | 5 2.5 => 1
- 2 | 2 1 => 0
- 2 | 1 0.5 = > 1
- now the final results : 101008
2- convert decimal to octal
1- convert 34 to octal
- 8 | 34 4.25 => 8 * .25 == 2
- 8 | 4 .5 => 8 * .5 == 4
- now the final results : 42, so in convert decimal to octal you divide
by 8 and if reminder then multipluy it's with 8 and make the same operation
unitl divide end with 0
2- convert 456 to octal
- 8 | 456 57(int number) => 0
- 8 | 57 7.125 => 8 * .125 == 1
- 8 | 7 0.875 => 8 * .875 == 7
- now the final results : 710
3- convert decimal to hexadecimal
1- convert 255 to hexadecimal
- 16 | 255 15.9375 => 16 * 0.9375 == 15 == f
- 16 | 15 0.9375 => 16 * 0.9375 == 15 == f
- now the final results : 0xff || 0x1515
1- convert 256 to hexadecimal
- 16 | 255 16 => 0
- 16 | 16 1 => 0
- 16 | 1 0.0625 => 0.0625 * 16 == 1
- now the final results : 100
continue:binary-convert.md