首页 万年历 正文内容

11111111转十进制(二进制11111111转十进制)

万年历 万年历 2022-12-17 05:42:32 1

大家好,近期很多朋友对于11111111转十进制产不是很理解。然后还有一些网友想弄清楚二进制11111111转十进制,已经为你找到了相关问题的答案,接下来和我们一起看看吧,希望对大家有所帮助!

NumberSystems/数字类型系统

Beforewegettoofaraheadofourselves,let'stakealookatthevariousnumbersystemsusedbyPLCs.

ManynumbersystemsareusedbyPLCs.BinaryandBinaryCodedDecimalarepopularwhileoctalandhexadecimalsystemsarealsocommon.

在我们超越自己之前,让我们先来看看PLC使用的各种数制系统。PLC使用许多数制系统,二进制和二进制编码的十进制很流行,而八进制和十六进制也很常见。

Let'slookateach:

让我们分别来看一下:

Aswedo,considerthefollowingformula(Mathagain!):

先看看下面的数学公式:

Nbase=Ddigit*R^unit+….D1R^1+D0R^0

whereD=thevalueofthedigitandR=#ofdigitsymbolsusedinthegivennumbersystem.

The"*"meansmultiplication.(5*10=50)

The"^"means"tothepowerof".

Asyou'llrecallanynumberraisedtothepowerof0is1.10^1=10,10^2is10×10=100,10^3is10x10x10=1000,10^4is10x10x10x10=10000…

其中D=给定数制系统中使用的数字的值,R=给定数制系统中使用的数字的符号#。

“*”表示乘法(比如5*10=50)。

“^”表示几次幂。

大家应该还记得0的任何次方都是1。10^1=10,10^2=10×10=100,10^3=10x10x10=1000……

Thisletsusconvertfromanynumbersystembackintodecimal.Huh?Readon…

这使得我们可以把任何数制系统转换成十进制。嗯,继续阅读吧……

  • Decimal–Thisisthenumberingsystemweuseineverydaylife.(wellmostofusdoanyway!)Wecanthinkofthisasbase10counting.Itcanbecalledasbase10becauseeachdigitcanhave10differentstates.(i.e.0-9)Sincethisisnoteasytoimplementinanelectronicsystemitisseldom,ifever,used.Ifweusetheformulaabovewecanfindoutwhatthenumber456is.Fromtheformula:Nbase=Ddigit*R^unit+….D1R^1+D0R^0
    wehave(sincewe'redoingbase10,R=10)

N10=D4*10^2+D5*10^1+D6*10^0

=4*10*10+5*10+6*1

=400+50+6

=456.

十进制数–这是我们在日常生活中最常使用的数字编码系统(反正我们大多数人都是这么做的)。我们可以把它看成是以10为基数的计数,它可以被称为以10为基底,因为这些数字可以有10种不同的状态(即0-9)。由于这在电子系统中不容易执行,因此很少使用在电子系统中,如果有的话,我们可以用上面的公式求出456是多少。

从公式Nbase=Ddigit*R^unit+….D1R^1+D0R^0

我们可以得出:(因为我们以10为基数,所以R=10)

N10=D4*10^2+D5*10^1+D6*10^0

=4*10*10+5*10+6*1

=400+50+6

=456.

  • Binary–ThisisthenumberingsystemcomputersandPLCsuse.Itwasfareasiertodesignasysteminwhichonly2numbers(0and1)aremanipulated(i.e.used).Thebinarysystemusesthesamebasicprinciplesasthedecimalsystem.Indecimalwehad10digits.(0-9)Inbinaryweonlyhave2digits(0and1).Indecimalwecount:0,1,2,3,4,5,6,7,8,9,andinsteadofgoingbacktozero,westartanewdigitandthenstartfrom0intheoriginaldigitlocation.
    Inotherwords,westartbyplacinga1intheseconddigitlocationandbegincountingagainintheoriginallocationlikethis10,11,12,13,…Whenagainwehit9,weincrementtheseconddigitandstartcountingfrom0againintheoriginaldigitlocation.Like20,21,22,23….ofcoursethiskeepsrepeating.Andwhenwerunoutofdigitsintheseconddigitlocationwecreateathirddigitandagainstartfromscratch.(i.e.99,100,101,102…)
    Binaryworksthesameway.Westartwith0then1.Sincethereisno2inbinarywemustcreateanewdigit.
    Thereforewehave0,1,10,11andagainwerunoutofroom.Thenwecreateanotherdigitlike100,101,110,111.Againweranoutofroomsoweaddanotherdigit…Doyougettheidea?
    Thegeneralconversionformulamayclearthingsup:
    Nbase=Ddigit*R^unit+….D1R^1+D0R^0.Sincewe'renowdoingbinaryorbase2,R=2.Let'strytoconvertthebinarynumber1101backintodecimal.

N10=D1*2^3+D1*2^2+D0*2^1+D1*2^0

=1*8+1*4+0*2+1*1

=8+4+0+1

=13

(ifyoudon'tseewherethe8,4,2,and1camefrom,refertothetablebelow).

二进制–这是计算机和PLC使用的数字编码系统。设计一个只操纵(或使用)两个数字(0和1)的系统要容易得多。

二进制系统使用与十进制系统相同的基本原则。十进制有10位数字(0-9),在二进制中,我们只有两位数字(0和1)。在十进制中,我们数:0、1、2、3、4、5、6、7、8、9,当达到9时我们不是回到0,而是从一个新的数字开始,然后在原始的数字位置从0开始。

换句话说,我们首先在第二个位置放一个1,然后在原来的位置重新开始计数,比如10、11、12、13、14、15、16、17、18、19,当再次达到9时,我们继续增加第二个位置的数字,并再从0开始在原始数字位置重新计数,比如20、21、22、23、24、25、26、27、28、29,当然这个过程一直重复。当第二个数字位置的数字用完时,我们创建第三个数字,然后从头开始(例如99、100、101、102、103、104、105、106、107、108、109)。

二进制也是如此。我们从0开始,然后是1,因为二进制中没有2,所以我们必须创建一个新的数字,如10、11,然后我们又没地方了,然后我们又创建另一个新的数字,比如100、101,再然后110、111,再然后1000、1001;1010、1011;1100、1101……这样一直继续,你明白了吗?

用下面的公式可能能解释清楚:Nbase=Ddigit*R^unit+….D1R^1+D0R^0.

因为我们现在用的是二进制或者以2为基数,所以R=2。让我们试着把二进制数字1101转换成十进制。

N10=D1*2^3+D1*2^2+D0*2^1+D1*2^0

=1*8+1*4+0*2+1*1

=8+4+0+1

=13

(如果您不知道8、4、2和1是从哪里来的,请参考下面的表)

Nowwecanseethatbinary1101isthesameasdecimal13.Trytranslatingbinary111.Youshouldgetdecimal7.Trybinary10111.Youshouldgetdecimal23.

现在我们可以看到二进制数1101和十进制数13是一样的。尝试翻译二进制数111,应该是十进制数7;试试二进制数10111,应该是十进制数23。

Here'sasimplebinarychartforreference.Thetoprowshowspowersof2whilethebottomrowshowstheirequivalentdecimalvalue.

这里有一个简单的二进制图供参考。第一行显示2的乘方,而后一行显示是它们的等效十进制数值。

  • Octal–Thebinarynumbersystemrequiresatonofdigitstorepresentalargenumber.Considerthatbinary11111111isonlydecimal255.Adecimalnumberlike1,000,000("1million")wouldneedalotofbinarydigits!Plusit'salsohardforhumanstomanipulatesuchnumberswithoutmakingmistakes.Thereforeseveralcomputer/plcmanufacturersstartedtoimplementtheoctalnumbersystem.Thissystemcanbethoughtofasbase8sinceitconsistsof8digits.(0,1,2,3,4,5,6,7)
    Sowecountlike0,1,2,3,4,5,6,7,10,11,12…17,20,21,22…27,30,…Usingtheformulaagain,wecanconvertanoctalnumbertodecimalquiteeasily.Nbase=Ddigit*R^unit+….D1R^1+D0R^0Sooctal654wouldbe:(rememberthathereR=8)
  • N10=D6*8^2+D5*8^1+D4*8^0

    =6*8*8+5*8+4*1

    =384+40+4

    =428

    (ifyoudon'tseewherethewhite64,8and1camefrom,refertothetablebelow).

    八进制–二进制数制系统需要大量的数字来表示一个较大的数字。考虑到二进制数11111111只是十进制数255,但像1,000,000(100万)这样的十进制数需要很多二进制数字来表示,此外,我们很难在不出错的情况下操纵这么多的数字。

    因此,一些计算机或者PLC制造商开始实施八进制数制系统。

    这个系统可以被认为是基于8的,因为它是由8位数字组成的(0,1,2,3,4,5,6,7)。

    所以我们数数0、1、2、3、4、5、6、7,10、11、12…17,20、21、22…27,30、31……。

    再次使用这个公式,我们可以很容易地把八进制数转换成十进制数:

    Nbase=Ddigit*R^unit+….D1R^1+D0R^0

    所以八进制654是(记住这里基数是8,即R=8):

    N10=D6*8^2+D5*8^1+D4*8^0

    =6*8*8+5*8+4*1

    =384+40+4

    =428

    (如果您不知道8、4、2和1是从哪里来的,请参考下面的表)。

    Nowwecanseethatoctal654isthesameasdecimal428.Trytranslatingoctal321.Youshouldgetdecimal209.Tryoctal76.Youshouldgetdecimal62.

    现在我们可以看到八进制数321和十进制数209是一样的。试着转换八进制数76,应该是十进制数62;试试八进制数100,应该是十进制数64。

    Here'sasimpleoctalchartforyourreference.Thetoprowshowspowersof8whilethebottomrowshowstheirequivalentdecimalvalue.

    这是一张简单的八进制表,供你参考。第一行显示8的乘方,而后一行显示它们的等效十进制数值。

    Lastly,theoctalsystemisaconvenientwayforustoexpressorwritebinarynumbersinplcsystems.Abinarynumberwithalargenumberofdigitscanbeconvenientlywritteninanoctalformwithfewerdigits.Thisisbecause1octaldigitactuallyrepresents3binarydigits.

    最后,八进制系统为我们在PLC系统中表达或写入二进制数字提供了方便。一个具有大量数位的二进制数可以用较少数位的八进制形式方便地写出来,这是因为一个八进制数实际上代表三个二进制数。

    Believemethatwhenwestartworkingwithregisterdataoraddresslocationsintheadvancedchaptersitbecomesagreatwayofexpressingdata.Thefollowingchartshowswhatwe'rereferringto:

    相信我,当我们在更高级的章节中开始处理寄存器数据或地址位时,它将成为表达数据的一种很好的方式。下面的图表显示了我们所讲到的情况:

    Fromthechartwecanseethatbinary1110010011100101isoctal162345.(decimal58597)Aswecansee,whenwethinkofregisters,it'seasiertothinkinoctalthaninbinary.Asyou'llsoonseethough,hexadecimalisthebestwaytothink.(really)

    从图表中我们可以看到二进制数1110010011100101是八进制数162345(十进制58597)。正如我们所看到的,当我们想到寄存器时,八进制比二进制更容易理解。不过,您很快就会看到,十六进制是最好的思考方式(真的)。

    • Hexadecimal–Thebinarynumbersystemrequiresatonofdigitstorepresentalargenumber.Theoctalsystemimprovesuponthis.Thehexadecimalsystemisthebestsolutionhowever,becauseitallowsustouseevenlessdigits.ItisthereforethemostpopularnumbersystemusedwithcomputersandPLCs.(weshouldlearneachonethough)Thehexadecimalsystemisalsoreferredtoasbase16orjustsimplyhex.Asthenamebase16implies,ithas16digits.Thedigitsare
      0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.Sowecountlike
      0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,13,…
      1A,1B,1C,1D,1E,1F,20,21…2A,2B,2C,2D,2E,2F,30…Usingtheformulaagain,wecanconvertahexnumbertodecimalquiteeasily.Nbase=Ddigit*R^unit+….D1R^1+D0R^0Sohex6A4wouldbe:(rememberherethatR=16)

    N10=D6*16^2+DA*16^1+D4*16^0

    =6*256+A(A=decimal10)*16+4*1

    =1536+160+4

    =1700

    (ifyoudon'tseewherethe256,16and1camefrom,refertothetablebelow)

    十六进制–二进制数制系统需要大量的数字来表示一个较大的数字。八进制系统在此基础上进行了改进,但不管怎么样十六进制是最好的解决方案,因为它允许我们使用更少的数字。因此,现在十六进制是计算机和PLC中使用的最流行的数字系统(当然我们应该了解每一种数制系统)。

    NowwecanseethathexFFFisthesameasdecimal4095.Trytranslatinghex76.Youshouldgetdecimal118.Tryhex100.Youshouldgetdecimal256.

    现在我们可以看到十六进制数FFF和十进制数4095是一样的。尝试转换十六进制数76,应该得到的十进制数是118;试试十六进制数100,应该得到的十进制数是256。

    Here'sasimplehexchartforreference.Thetoprowshowspowersof16whilethebottomrowshowstheirequivalentdecimalvalue.Noticethatthenumbersgetlargeratherquickly!

    这里有一个简单的十六进制图表供参考。第一行显示16的乘方,而后一行显示它们的等效的十进制数值。注意,你可以看到数字会很快变大!

    Finally,thehexsystemisperhapsthemostconvenientwayforustoexpressorwritebinarynumbersinplcsystems.Abinarynumberwithalargenumberofdigitscanbeconvenientlywritteninhexformwithfewerdigitsthanoctal.Thisisbecause1hexdigitactuallyrepresents4binarydigits.

    最后,十六进制系统可能是我们在PLC系统中表达或写入二进制数最方便的方法。一个有大量数字的二进制数可以用比八进制数更少的数字写成十六进制形式,这是因为1个十六进制数字实际上代表4个二进制数字。

    Believemethatwhenwestartworkingwithregisterdataoraddresslocationsintheadvancedchaptersitbecomesthebestwayofexpressingdata.Thefollowingchartshowswhatwe'rereferringto:

    相信我,当我们在更高级章节中开始处理寄存器数据或地址位时,十六进制将成为我们表达数据的最佳方式。下面的图表显示了我们所讲到的情况:

    Fromthechartwecanseethatbinary0111010010100101ishex74A5.(decimal29861)Aswecansee,whenwethinkofregisters,it'sfareasiertothinkinhexthaninbinaryoroctal.

    从图中我们可以看到二进制数0111010010100101是十六进制数74A5(十进制数29861)。正如我们所看到的,当我们想到寄存器时,用十六进制比用二进制或八进制要容易得多。

    文章目录
      搜索