二进制、十进制、十六进制转换
- 格式:docx
- 大小:23.86 KB
- 文档页数:9
进制转化公式进制转化是数学中一个常见的操作,用于将数字在不同进制之间进行转换。
进制是数学表示法的一种方式,不同进制对应着不同的基数。
目前常用的进制有十进制、二进制、八进制和十六进制。
在十进制中,我们使用0-9这十个数字进行计数。
例如数字456表示的意思是4乘以100加5乘以10加6乘以1。
而在二进制中,只使用0和1进行计数。
例如数字101表示的意思是1乘以4加0乘以2加1乘以1。
八进制和十六进制则使用了更多的符号表示数值,分别使用0-7和0-9以及A-F这些字符进行计数。
进制转化的公式主要根据进制的特点来进行推导,以下是一些常见的进制转化公式:1. 十进制转二进制:将十进制数不断除以2,直到商为0,然后将每一步的余数倒序排列即可得到二进制数。
2. 二进制转十进制:将二进制数从右到左,每一位乘以2的相应指数,再将结果相加即可得到十进制数。
3. 十进制转八进制:将十进制数不断除以8,直到商为0,然后将每一步的余数倒序排列即可得到八进制数。
4. 八进制转十进制:将八进制数从右到左,每一位乘以8的相应指数,再将结果相加即可得到十进制数。
5. 十进制转十六进制:将十进制数不断除以16,直到商为0,然后将每一步的余数倒序排列,并将10-15分别用A-F表示即可得到十六进制数。
6. 十六进制转十进制:将十六进制数从右到左,每一位乘以16的相应指数,再将结果相加即可得到十进制数。
通过以上公式,我们可以在不同进制之间进行转化。
进制转化不仅在数学中有着重要的应用,同时在计算机科学和信息技术领域也扮演着重要的角色。
例如,计算机内部使用二进制进行数据存储和计算,而网络通信中常使用十六进制表示数据。
掌握进制转化公式对于进行数值计算和理解计算机科学原理非常重要。
能够灵活运用进制转化公式,不仅可以提高计算效率,还能深入理解进制的含义和应用。
因此,我们需要在数学学习的过程中,仔细掌握并灵活运用进制转化公式,以便在实际应用中取得更好的成果。
二进制八进制十进制十六进制之间的进制转换详情可参考百度百科:进制转换这个词条【主要搞懂1和2两条,其他的进制之间的转化就迎刃而解,很好懂了】1. 十进制-> 二进制:将这个十进制数连续除以2的过程,第一步除以2,得到商和余数,将商再继续除以2,得到又一个商和余数,直到商为0。
最后将所有余数倒序排列,得到的数就是转换成二进制的结果。
2. 二进制-> 十进制:二进制数第1位的权值是2的0次方,第2位的权值是2的1次方,第3位的权值是2的2次方。
(例如1258这个十进制数,实际上代表的是:1x1000+2x100+5x10+8x1=1258)那么1011这个二进制数,实际上代表的是:1x8+0x4+1x2+1x1=11(十进制数11)。
(这里的8就是2的3次方,4就是2的2次方,2就是2的1次方,1就是2的0次方)3. 十进制-> 八进制:十进制数转换成八进制的方法,和转换为二进制的方法类似,唯一变化:除数由2变成8。
4. 八进制-> 十进制和转换为二进制的方法类似,唯一变化是,底数变成8,第1位表示8的0次方,第二位表示8的一次方,第三位表示8的2次方,第四位表示8的3次方。
例如1314这个八进制数,十进制数就是1x512+3x64+1x8+4x1=716(十进制)5. 十进制-> 十六进制10进制数转换成16进制的方法,和转换为2进制的方法类似,唯一变化:除数由2变成16。
十六进制是0123456789ABCDEF这十六个字符表示。
那么单独一个A就是10,单独一个B就是11,CDEF,就分表表示12,13,14,15。
而10这个十六进制数,实际就是十进制中的16。
6. 十六进制-> 十进制和转换为二进制的方法类似,唯一变化是,底数变成16,第1位表示16的0次方,第二位表示16的一次方,第三位表示16的2次方,第四位表示16的3次方。
7. 二进制<--->八进制,之间的相互转换,更简单一些,因为8本身是2的三次方。
二进制八进制十进制十六进制之间的转换算法二进制、八进制、十进制和十六进制是计算机中常用的数字表示方法。
它们之间的转换可以通过一些算法来实现。
下面将介绍这些算法,并给出详细的解释。
1.二进制转八进制:将二进制数从右往左每3位一组进行分组,不足3位的可以在左侧补0。
然后将每组的二进制数转换为对应的八进制数。
如:分组:11010110转换为八进制数:3262.二进制转十进制:二进制数转换为十进制数可以使用加权的方式计算。
从最右边的位开始,每一位的值乘以2的对应次幂(从0开始),然后将所有结果相加。
如:二进制数:1101转换为十进制数:(1*2^3)+(1*2^2)+(0*2^1)+(1*2^0)=133.二进制转十六进制:将二进制数从右往左每4位一组进行分组,不足4位的可以在左侧补0。
然后将每组的二进制数转换为对应的十六进制数。
如:分组:110110101转换为十六进制数:DA14.八进制转二进制:将八进制数的每一位转换为对应的3位二进制数。
如:八进制数:326转换为二进制数:0110101105.八进制转十进制:八进制数转换为十进制数可以使用加权的方式计算。
从最右边的位开始,每一位的值乘以8的对应次幂(从0开始),然后将所有结果相加。
如:八进制数:326转换为十进制数:(3*8^2)+(2*8^1)+(6*8^0)=2146.八进制转十六进制:先将八进制数转换为二进制数,然后将二进制数转换为十六进制数。
如:八进制数:326转换为二进制数:011010110转换为十六进制数:DA67.十进制转二进制:十进制数转换为二进制数可以使用除2取模的方式计算。
将十进制数一直除以2,直到商为0为止,然后将每一步的余数倒序排列即可。
如:十进制数:13转换为二进制数:11018.十进制转八进制:十进制数转换为八进制数可以使用除8取模的方式计算。
将十进制数一直除以8,直到商为0为止,然后将每一步的余数倒序排列即可。
如:十进制数:214转换为八进制数:3269.十进制转十六进制:十进制数转换为十六进制数也可以使用除法和取模的方式计算。
整数的十进制、二进制、八进制、十六进制表示和转换方式整数的不同进制表示方法是计算机科学中基本的知识之一。
在现代计算机中,二进制和十六进制是特别常用的进制,而八进制则进行很少的使用。
在本文中,我们将详细介绍整数的不同进制,以及如何在它们之间进行转换。
一、十进制表示十进制是我们常用的进制,它是使用十个数字 0 到 9 表示的。
以整数12345 为例,它在十进制下的表示方法为:12345(10)二、二进制表示在计算机中,二进制是计算机所使用的进制。
它仅使用 0 和 1 两个数字来表示。
以整数 12345 为例,它在二进制下的表示方法为:11000000111001(2)二进制转换为十进制时,将每个数位上的数乘以该数位所对应的 2 的幂次方,然后将乘积相加即可得到十进制结果。
二进制转换为十六进制时,将二进制数从右往左每 4 位分为一组,不足 4 位的高位补零,然后将每一组转换为一个十六进制数即可。
三、八进制表示八进制是由 0 到 7 这八个数字组成的一个进制。
在计算机科学中,它比较少被使用。
以整数 12345 为例,它在八进制下的表示方法为:30071(8)八进制转换为十进制时,将每个数位上的数乘以该数位所对应的 8 的幂次方,然后将乘积相加即可得到十进制结果。
八进制转换为十六进制时,将八进制数从右往左每 3 位分为一组,不足 3 位的高位补零,然后将每一组转换为一个十六进制数即可。
四、十六进制表示十六进制是由 0 到 9 这十个数字和 A 到 F 这六个字母共 16 个字符组成的进制。
在计算机科学中,它也是比较常用的进制之一。
以整数 12345 为例,它在十六进制下的表示方法为:3039(16)十六进制转换为十进制时,将每个数位上的数乘以该数位所对应的 16的幂次方,然后将乘积相加即可得到十进制结果。
十六进制转换为二进制时,将十六进制数每一位转换为 4 位的二进制数即可。
综上所述,整数的不同进制表示方法在计算机科学中是非常重要的。
二进制、八进制、十进制、十六进制之间转换一、十进制与二进制之间的转换(1)十进制转换为二进制,分为整数部分和小数部分①整数部分方法:除2取余法,即每次将整数部分除以2,余数为该位权上的数,而商继续除以2,余数又为上一个位权上的数,这个步骤一直持续下去,直到商为0为止,最后读数时候,从最后一个余数读起,一直到最前面的一个余数。
下面举例:例:将十进制的168转换为二进制得出结果将十进制的168转换为二进制,(10101000)2分析:第一步,将168除以2,商84,余数为0。
第二步,将商84除以2,商42余数为0。
第三步,将商42除以2,商21余数为0。
第四步,将商21除以2,商10余数为1。
第五步,将商10除以2,商5余数为0。
第六步,将商5除以2,商2余数为1。
第七步,将商2除以2,商1余数为0。
第八步,将商1除以2,商0余数为1。
第九步,读数,因为最后一位是经过多次除以2才得到的,因此它是最高位,读数字从最后的余数向前读,即10101000(2)小数部分方法:乘2取整法,即将小数部分乘以2,然后取整数部分,剩下的小数部分继续乘以2,然后取整数部分,剩下的小数部分又乘以2,一直取到小数部分为零为止。
如果永远不能为零,就同十进制数的四舍五入一样,按照要求保留多少位小数时,就根据后面一位是0还是1,取舍,如果是零,舍掉,如果是1,向入一位。
换句话说就是0舍1入。
读数要从前面的整数读到后面的整数,下面举例:例1:将0.125换算为二进制得出结果:将0.125换算为二进制(0.001)2分析:第一步,将0.125乘以2,得0.25,则整数部分为0,小数部分为0.25;第二步, 将小数部分0.25乘以2,得0.5,则整数部分为0,小数部分为0.5;第三步, 将小数部分0.5乘以2,得1.0,则整数部分为1,小数部分为0.0;第四步,读数,从第一位读起,读到最后一位,即为0.001。
例2,将0.45转换为二进制(保留到小数点第四位)大家从上面步骤可以看出,当第五次做乘法时候,得到的结果是0.4,那么小数部分继续乘以2,得0.8,0.8又乘以2的,到1.6这样一直乘下去,最后不可能得到小数部分为零,因此,这个时候只好学习十进制的方法进行四舍五入了,但是二进制只有0和1两个,于是就出现0舍1入。
二进制数八进制数十进制数十六进制数相互转换方法二进制、八进制、十进制和十六进制是常用的数值系统,它们在计算机科学、电子工程和计量学等领域有广泛的应用。
本文将介绍二进制到八进制、十进制、十六进制的转换方法,以及这些数制之间的互相转换方法。
一、二进制数转换为八进制数、十进制数和十六进制数:1.二进制数转换为八进制数:111001->712.二进制数转换为十进制数:从二进制数的右侧开始,将每一位的值与对应的权重进行相乘,然后将乘积相加,即可得到十进制数。
例如,二进制数1011转换为十进制数的步骤如下:1*2^3+0*2^2+1*2^1+1*2^0=8+0+2+1=11因此,二进制数1011转换为十进制数113.二进制数转换为十六进制数:10011010->9A二、八进制数转换为二进制数、十进制数和十六进制数:1.八进制数转换为二进制数:将八进制数的每一位转换为对应的3位二进制数。
例如,八进制数71转换为二进制数的步骤如下:7->1111->0012.八进制数转换为十进制数:从八进制数的右侧开始,将每一位的值与对应的权重进行相乘,然后将乘积相加,即可得到十进制数。
例如,八进制数71转换为十进制数的步骤如下:7*8^1+1*8^0=56+1=57因此,八进制数71转换为十进制数573.八进制数转换为十六进制数:将八进制数转换为二进制数,然后将二进制数转换为十六进制数。
例如,八进制数71转换为十六进制数的步骤如下:7->1111->001111001->9A因此,八进制数71转换为十六进制数9A。
三、十进制数转换为二进制数、八进制数和十六进制数:1.十进制数转换为二进制数:将十进制数不断除以2,直到商为0,将每一步的余数按从低位到高位的顺序排列,即可得到对应的二进制数。
例如,十进制数11转换为二进制数的步骤如下:11/2=5余15/2=2余12/2=1余01/2=0余1因此,十进制数11转换为二进制数10112.十进制数转换为八进制数:将十进制数不断除以8,直到商为0,将每一步的余数按从低位到高位的顺序排列,即可得到对应的八进制数。
⼆进制,⼋进制,⼗进制,⼗六进制的相互转换常⽤进制数:⼆进制,⼋进制,⼗进制,⼗六进制进制理解计算机中硬件之间的信息传递是由电流确定,假如⼀个半导体允许通过的电流是5A,如果电流通过的为5A,则通过,计为1,如果通过的电流⼩于5A,则不通过,计为0。
由此,出现两种情况的判断,与或⾮。
电流的传递由0或1来完成,由此引申出⼆进制数的概念,以便底层硬件有共同的“语⾔”,即机器语⾔,相互沟通和交流。
我们⽣活中⼀般数值的运算是⼗进制。
就是满10进1,个⼗百千万,依次递进。
由此,可以类⽐。
⼆进制(Binary):0,1。
基数为2,逢⼆进⼀。
表⽰:(111)2或者(111)B⼋进制(Octal number system):0,1,2,3,4,5,6,7。
基数为8,逢⼋进⼀。
表⽰:(111)8或者(111)O⼗进制(Decimal system):0,1,2,3,4,5,6,7,8,9。
基数为10,逢⼗进⼀。
表⽰:(111)10或者(111)D⼗六进制(Hexadecimal):0,1,2,3,4,5,6,7,8,9,A(10),B(11),C(12),D(13),E(14),F(15)。
基数为16,逢⼗六进⼀。
表⽰:(111)16或者(111)Hn进制:(逢n进1)个位数:n0( 0个8)⼗位数:n1( 1个8)百位数:n2( 8个8)进制转换1.⼗进制转其他进制① 除⼆取余法(整数部分):把被转换的⼗进制整数反复除以2,直⾄商为0,所得的余数(从末位读起)就是这个数的⼆进制表⽰。
② 乘⼆取整法(⼩数部分):将⼩数部分乘以2,然后取整数部分,剩下的⼩数部分继续乘以2,然后取整数部分,剩下的⼩数部分⼜乘以2,⼀直取到⼩数部分为零为⽌。
如果永远不能为零,就同⼗进制数的四舍五⼊⼀样,按照要求保留多少位⼩数时,就根据后⾯⼀位是0还是1,取舍,如果是零,舍掉,如果是1,向⼊⼀位。
换句话说就是0舍1⼊。
读数要从前⾯的整数读到后⾯的整数。
计算机进制之间的转换进制是计算机中用于表示数值的一组符号系统,包括二进制、八进制、十进制和十六进制等。
在计算机科学中,进制转换是一种常见且重要的操作。
本文将详细介绍计算机进制之间的转换方法。
1. 二进制 (Binary) 转换为十进制 (Decimal):方法1:将二进制数从右往左按位展开,每一位的值与2的幂相乘,然后将得到的结果相加。
例如,二进制数1101转换为十进制,计算过程如下:(1*2^3)+(1*2^2)+(0*2^1)+(1*2^0)=13方法2:使用公式法。
将二进制数从高位到低位按权展开,并将每一位的值乘以相应权重,然后将结果相加。
例如,二进制数1101转换为十进制,计算过程如下:(1*2^3)+(1*2^2)+(0*2^1)+(1*2^0)=132. 十进制 (Decimal) 转换为二进制 (Binary):方法1:使用除二取余法。
将十进制数从右往左不断除以2,直到商为0。
最后,将得到的余数按照从下往上的顺序排列,即为二进制数。
例如,十进制数13转换为二进制,计算过程如下:13÷2=商6、余16÷2=商3、余03÷2=商1、余11÷2=商0、余1将得到的余数按从下往上的顺序排列,即为二进制数1101方法2:使用公式法。
将十进制数转换为相应的二进制幂的和。
例如,十进制数13转换为二进制,计算过程如下:13=(2^3)+(2^2)+(2^0)=11013. 十进制 (Decimal) 转换为八进制 (Octal):方法1:使用除八取余法。
将十进制数从右往左不断除以8,直到商为0。
最后,将得到的余数按从下往上的顺序排列,即为八进制数。
例如,十进制数86转换为八进制,计算过程如下:86÷8=商10、余610÷8=商1、余21÷8=商0、余1将得到的余数按从下往上的顺序排列,即为八进制数126方法2:使用公式法。
将十进制数转换为相应的八进制幂的和。
1、二进制转为八进制110110010.100101(2)→110'110'010.100'101(2)=662.45(8)。
2、二进制转为十进制110110010.100101(2)=1*2^8+1*2^7+0*2^6+1*2^5+1*2^4+0*2^3+0*2^2+1*2^1+0*2^0+1*2^( -1)+0*2^(-2)+0*2^(-3)+1*2^(-4)+0*2^(-5)+1*2^(-6)=256+128+0+32+16+0+0+2+0+1/2+0+0+1/16+0+1/64=434.578125(10)。
3、二进制转为十六进制110110010.100101(2)→1'1011'0010.1001'01(2)→0001'1011'0010.1001'0100(2)=1B2.94(16)。
进位制/位置计数法是一种记数方式,故亦称进位记数法/位值计数法,可以用有限的数字符号代表所有的数值。
可使用数字符号的数目称为基数或底数,基数为n,即可称n进位制,简称n进制。
现在最常用的是十进制,通常使用10个阿拉伯数字0-9进行记数。
扩展资料:二进制数的四则运算二进制数与十进制数一样,同样可以进行加、减、乘、除四则运算。
其算法规则如下:加运算:0 0=0,0 1=1,1 0=1,1 1=10,#逢2进1;减运算:1-1=0,1-0=1,0-0=0,0-1=1,#向高位借1当2;乘运算:0×0=0,0×1=0,1×0=0,1×1=1,#只有同时为“1”时结果才为“1”;除运算:二进制数只有两个数(0,1),因此它的商是1或0。
什么是二进制在现实生活和记数器中,如果表示数的“器件”只有两种状态,如电灯的“亮”与“灭”,开关的“开”与“关”。
一种状态表示数码0,另一种状态表示数码1,1加1应该等于2,因为没有数码2,只能向上一个数位进一,就是采用“满二进一”的原则,这和十进制是采用“满十进一”原则完全相同。
1+1=10,10+1=11,11+1=100,100+1=101,101+1=110,110+1=111,111+1+=1000,……,可见二进制的10表示二,100表示四,1000表示八,10000表示十六,……。
二进制同样是“位值制”。
同一个数码1,在不同数位上表示的数值是不同的。
如11111,从右往左数,第一位的1就是一,第二位的1表示二,第三位的1表示四,第四位的1表示八,第五位的1表示十六。
所谓二进制,也就是计算机运算时用的一种算法。
二进制只由一和零组成。
比方说吧,你上一年级时一定听说过“进位筒”&“数位筒”吧!十进制是个位上满十根小棒就捆成一捆,放进十位筒,十位筒满十捆就捆成一大捆,放进百位筒……二进制也是一样的道理,个位筒上满2根就向十位进一,十位上满两根就向百位进一,百位上满两根……二进制是世界上第一台计算机上用的算法,最古老的计算机里有一个个灯泡,当运算的时候,比如要表达“一”,第一个灯泡会亮起来。
要表达“二”,则第一个灯泡熄灭,第二个灯泡就会亮起来。
二进制就是等于2时就要进位。
0=00000000 1=00000001 2=00000010 3=00000011 4=00000100 5=000 001016=00000110 7=00000111 8=00001000 9=00001001 10=00001010 ……即是逢二进一,二进制广泛用于最基础的运算方式,计算机的运行计算基础就是基于二进制来运行。
只是用二进制执行运算,用其他进制表现出来。
其实把二进制三位一组分开就是八进制, 四位一组就是十六进制NAMEbin_dec_hex - How to use binary, decimal, and hexadecimal notation.DESCRIPTIONMost people use the decimal numbering system. This system uses ten symbols to represent numbers. When those ten symbols are used up, they start all over again and increment the position to the left. The digit 0 is only shown if it is the only symbol in the sequence, or if it is not the first one.If this sounds cryptic to you, this is what I've just said in numbers:0 1 2 3 4 5 6 7 8 9 10 11 12 13 and so on.Each time the digit nine is incremented, it is reset to 0 and the position before (to the left) is incremented (from 0 to 1). Then number 9 can be seen as ``00009'' and when we should increment 9, we reset it to zero and increment the digit just before the 9 so the number becomes ``00010''. Leading zeros we don't write except if it is the only digit (number 0). And of course, we write zeros if they occur anywhere inside or at the end of a number:"00010" -> " 0010" -> " 010" -> " 10", but not " 1 ".This was pretty basic, you already knew this. Why did I tell it? Well, computers usually do not represent numbers with 10 different digits. They only use two different symbols, namely ``0'' and ``1''. Apply the same rules to this set of digits and you get the binary numbering system:0 1 10 11100101110111100010011010101111001101 and so on.If you count the number of rows, you'll see that these are again 14 different numbers. The numbers are the same and mean the same as in the first list, we just used a different representation. This means that you have to know the representation used, or as it is called the numbering system or base. Normally, if we do not explicitly specify the numbering system used, we implicitly use the decimal system. If we want to use any other numbering system, we'll have to make that clear. There are a few widely adopted methods to do so. One common form is to write 1010(2) which means that you wrote down a number in its binary representation. It is the number ten. If you would write 1010 without specifying the base, the number is interpreted as one thousand and ten using base 10.In books, another form is common. It uses subscripts (little characters, more or less in between two rows). You can leave out the parentheses in that case and write down the number in normal characters followed by a little two just behind it.As the numbering system used is also called the base, we talk of the number 1100 base 2, the number 12 base 10.Within the binary system, it is common to write leading zeros. The numbers are written down in series of four, eight or sixteen depending on the context.We can use the binary form when talking to computers (...programming...), but the numbers will have large representations. The number 65'535 (often in the decimal system a ' is used to separate blocks of three digits for readability) would be written down as1111111111111111(2) which is 16 times the digit 1. This is difficult and prone to errors. Therefore, we usually would use another base, called hexadecimal. It uses 16 different symbols. First the symbols from the decimal system are used, thereafter we continue with alphabetic characters. We get 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. This system is chosen because the hexadecimal form can be converted into the binary system very easily (and back).There is yet another system in use, called the octal system. This was more common in the old days, but is not used very often anymore. As you might find it in use sometimes, you should get used to it and we'll show it below. It's the same story as with the other representations, but with eight different symbols.Binary (2)Octal (8)Decimal (10)Hexadecimal (16)(2) (8) (10) (16)00000 0 0 000001 1 1 100010 2 2 200011 3 3 300100 4 4 400101 5 5 500110 6 6 600111 7 7 701000 10 8 801001 11 9 901010 12 10 A01011 13 11 B01100 14 12 C01101 15 13 D01110 16 14 E01111 17 15 F10000 20 16 1010001 21 17 1110010 22 18 1210011 23 19 1310100 24 20 1410101 25 21 15Most computers used nowadays are using bytes of eight bits. This means that they store eight bits at a time. You can see why the octal system is not the most practical for that: You'd need three digits to represent the eight bits and this means that you'd have to use one complete digit to represent only two bits(2+3+3=8). This is a waste. For hexadecimal digits, you need only two digits which are used completely:(2) (8) (10) (16)11111111 377 255 FFYou can see why binary and hexadecimal can be converted quickly: For each hexadecimal digit there are exactly four binary digits. Take a binary number: take four digits from the right and make a hexadecimal digit from it (see the table above). Repeat this until there are no more digits. And the other way around: Take a hexadecimal number. For each digit, write down its binary equivalent.Computers (or rather the parsers running on them) would have a hard time converting a number like 1234(16). Therefore hexadecimal numbers are specified with a prefix. This prefix depends on the language you're writing in. Some of the prefixes are ``0x'' for C, ``$'' for Pascal, ``#'' for HTML. It is common to assume that if a number starts with a zero, it is octal. It does not matter what is used as long as you know what it is. I will use ``0x'' for hexadecimal, ``%'' for binary and ``0'' for octal. The following numbers are all the same, just their representation (base) is different: 021 0x11 17 %00010001To do arithmetics and conversions you need to understand one more thing. It is something you already know but perhaps you do not ``see'' it yet:If you write down 1234, (no prefix, so it is decimal) you are talking about the number one thousand, two hundred and thirty four. In sort of a formula:1 * 1000 = 10002 * 100 = 2003 * 10 = 304 * 1 = 4This can also be written as:1 * 10^32 * 10^23 * 10^14 * 10^0where ^ means ``to the power of''.We are using the base 10, and the positions 0,1,2 and 3. The right-most position should NOT be multiplied with 10. The second from the right should be multiplied one time with 10. The third from the right is multiplied with 10 two times. This continues for whatever positions are used.It is the same in all other representations:0x1234 will be1 * 16^32 * 16^23 * 16^14 * 16^001234 would be1 * 8^32 * 8^23 * 8^14 * 8^0This example can not be done for binary as that system only uses two symbols. Another example:%1010 would be1 * 2^30 * 2^21 * 2^10 * 2^0It would have been easier to convert it to its hexadecimal form and just translate %1010 into 0xA. After a while you get used to it. You will not need to do any calculations anymore, but just know that 0xA means 10.To convert a decimal number into a hexadecimal you could use the next method. It will take some time to be able to do the estimates, but it will be easier when you use the system more frequently. We'll look at yet another way afterwards.First you need to know how many positions will be used in the other system. To do so, you need to know the maximum numbers you'll be using. Well, that's not as hard as it looks. In decimal, the maximum number that you can form with two digits is ``99''. The maximum for three: ``999''. The next number would need an extra position. Reverse this idea and you will see that the number can be found by taking 10^3 (10*10*10 is 1000) minus 1 or 10^2 minus one.This can be done for hexadecimal as well:16^4 = 0x10000 = 6553616^3 = 0x1000 = 409616^2 = 0x100 = 25616^1 = 0x10 = 16If a number is smaller than 65'536 it will fit in four positions. If the number is bigger than 4'095, you must use position 4. How many times you can subtract4'096 from the number without going below zero is the first digit you write down. This will always be a number from 1 to 15 (0x1 to 0xF). Do the same for the other positions.Let's try with 41'029. It is smaller than 16^4 but bigger than 16^3-1. This means that we have to use four positions. We can subtract 16^3 from 41'029 ten times without going below zero. The left-most digit will therefore be ``A'', so we have0xA????. The number is reduced to 41'029 - 10*4'096 = 41'029-40'960 = 69. 69 is smaller than 16^3 but not bigger than 16^2-1. The second digit is therefore ``0'' and we now have 0xA0??. 69 is smaller than 16^2 and bigger than 16^1-1. We can subtract 16^1 (which is just plain 16) four times and write down ``4'' to get0xA04?. Subtract 64 from 69 (69 - 4*16) and the last digit is 5 --> 0xA045.The other method builds up the number from the right. Let's try 41'029 again. Divide by 16 and do not use fractions (only whole numbers).41'029 / 16 is 2'564 with a remainder of 5. Write down 5.2'564 / 16 is 160 with a remainder of 4. Write the 4 before the 5. 160 / 16 is 10 with no remainder. Prepend 45 with 0.10 / 16 is below one. End here and prepend 0xA. End up with 0xA045.Which method to use is up to you. Use whatever works for you. I use them both without being able to tell what method I use in each case, it just depends on the number, I think. Fact is, some numbers will occur frequently while programming. If the number is close to one I am familiar with, then I will use the first method (like 32'770 which is into 32'768 + 2 and I just know that it is 0x8000 + 0x2 = 0x8002).For binary the same approach can be used. The base is 2 and not 16, and the number of positions will grow rapidly. Using the second method has the advantage that you can see very easily if you should write down a zero or a one: if you divide by two the remainder will be zero if it is an even number and one if it is an odd number:41029 / 2 = 20514 remainder 120514 / 2 = 10257 remainder 010257 / 2 = 5128 remainder 15128 / 2 = 2564 remainder 02564 / 2 = 1282 remainder 01282 / 2 = 641 remainder 0641 / 2 = 320 remainder 1320 / 2 = 160 remainder 0160 / 2 = 80 remainder 080 / 2 = 40 remainder 040 / 2 = 20 remainder 020 / 2 = 10 remainder 010 / 2 = 5 remainder 05 / 2 = 2 remainder 12 / 2 = 1 remainder 01 /2 below 0 remainder 1Write down the results from right to left: %1010000001000101Group by four:%1010000001000101%101000000100 0101%10100000 0100 0101%1010 0000 0100 0101Convert into hexadecimal: 0xA045Group %1010000001000101 by three and convert into octal:%1010000001000101%1010000001000 101%1010000001 000 101%1010000 001 000 101%1010 000 001 000 101%1 010 000 001 000 101%001 010 000 001 000 1011 2 0 1 0 5 --> 0120105So: %1010000001000101 = 0120105 = 0xA045 = 41029Or: 1010000001000101(2) = 120105(8) = A045(16) = 41029(10)Or: 1010000001000101(2) = 120105(8) = A045(16) = 41029At first while adding numbers, you'll convert them to their decimal form and then back into their original form after doing the addition. If you use the other numbering system often, you will see that you'll be able to do arithmetics directly in the base that is used. In any representation it is the same, add the numbers on the right, write down the right-most digit from the result, remember the other digits and use them in the next round. Continue with the second digit from the right and so on:%1010 + %0111 --> 10 + 7 --> 17 --> %00010001will become%1010%0111 +|||||||+-- add 0 + 1, result is 1, nothing to remember||+--- add 1 + 1, result is %10, write down 0 and remember 1|+---- add 0 + 1 + 1(remembered), result = 0, remember 1+----- add 1 + 0 + 1(remembered), result = 0, remember 1nothing to add, 1 remembered, result = 1--------%10001 is the result, I like to write it as %00010001For low values, try to do the calculations yourself, then check them with a calculator. The more you do the calculations yourself, the more you'll find that you didn't make mistakes. In the end, you'll do calculi in other bases as easily as you do them in decimal.When the numbers get bigger, you'll have to realize that a computer is not called a computer just to have a nice name. There are many different calculators available, use them. For Unix you could use ``bc'' which is short for Binary Calculator. It calculates not only in decimal, but in all bases you'll ever want to use (among them Binary).For people on Windows: Start the calculator (start->programs->accessories->calculator) and if necessary click view->scientific. You now have a scientific calculator and can compute in binary or hexadecimal.AUTHORI hope you enjoyed the examples and their descriptions. If you do, help other people by pointing them to this document when they are asking basic questions. They will not only get their answer, but at the same time learn a whole lot more.。