Octal

Introduction

Octal,abbreviatedOCTorO,isacountingmethodbasedon8anduses0,1,2,3,4,5,6,7eightnumbers,Everyeightenters1.Someprogramminglanguages​​oftenstartwiththenumber0toindicatethatthenumberisoctal.Octalnumbersandbinarynumberscancorrespondbitbybit(onebitinoctalcorrespondstothreebitsinbinary),sotheyareoftenusedincomputerlanguages.

Octal(base8)notationisverycommonincomputersystems,sowecansometimesseepeopleusingoctalnotation.Sinceonehexadecimaldigitcancorrespondto4binarydigits,itismoreconvenienttousehexadecimaltorepresentbinary.Therefore,theapplicationofoctalisnotasgoodashexadecimal.Therearesomeprogramminglanguages​​thatprovidetheabilitytouseoctalnotationtorepresentnumbers,andtherearestillsomeolderUnixapplicationsthatuseoctal.

Computersneednumbersystemconversion.Thecomputerusesbinarysysteminternally.ThenumbersystemconversionbetweenbinaryoctalsystemanddecimalsystemiscompiledbyFORTRAN77.Theconversionbetweenbinarysystemanddecimalsystemiscompletedaroundbinaryanddecimal.

>

Somepeoplehavesuggestedthattheword"nine"intheprimitiveIndo-Europeanlanguagefamilymaybetheword"new"withthefaction.Onthisbasis,itwasspeculatedthattheoriginalIndo-Europeanlanguagefamilyusedanoctalnumbersystem.

AnarticlebyJohnWilkinsin1668proposedtoarealsystemandphilosophicallanguagetouse8asthebasenumberinsteadof10,becausethedichotomytodividethenumberintotwopartsisthemostnaturalAccordingtothis,thisnumbercanbeunifiedwiththenextvalue.

In1716,KingCharlesXIIofSwedenorderedSwedenborgtostatethatthebasenumberis64insteadof10.However,Swedenborgthinksthatpeoplewithlowerintelligencethanthekingaretoodifficulttounderstand,soitputs8asthebase.Whatisthenumber1-7withtheconsonantl,year,n,m,t,f,u(v)andthezerovowelo.Therefore,8="lo",16="so",24="no",64="loo",512="looo"andotherdigitalcontinuousconsonantsandvowelsarepronouncedinaccordancewithspecialrules.[5]

InJuly1745,HughJonesproposedanoctalsystemforBritishcoins,weightsandmeasures.Thereasonistotellusthataunifiedstandardismoreconvenientforallquantities;itiscalledtheGeorgianstandard;itdivideseachintegerintoeightequalparts,andeachpartisdividedinto8realorimaginaryexamples.Atthattime,allcountriesgenerallyusedthebasetens(thenumberofthefirsthands),but8isamorecompleteandspaciousnumber;becauseitisdividedbyhalf,quarters,halfquarters(orunits)havenoscores,easytosubdivide...Eveninthelaterdiscussion"JonesofEightDigits(1753)thinks:"Octalarithmeticseemstobethemostdesirablething,andatthesametimeitisclosesttotheessenceofthings,soitcanbecalledthemostnaturalnumber,althoughitisnowopposedtoitsuse.Decadeslater;thismaybepopulararithmetic."

In1801,JamesAndersoncriticizedtheFrenchmetricsystembasedondecimalarithmetic.Underhissuggestion,hecreatedtheoctalsystem.ProposedapureoctalsystemofweightsandmeasuresandobservedthattheexistingsystemEnglishunitshavebeenlargelyItevolvedintoanoctalsystem.

Inthemiddleofthe19thcentury,AlfredTaylorbelieved,"Ifweuseeightbases,thenwewillsurpassallcountingmethods"becauseitisthebestarithmeticsystem"."Theproposalincludesanewnumberofgraphicsymbolsandanewnameofthenumber",includingunty,duty,thety,fotyi>,paty,sety,kityandunderetc.Forexample,thenumber65decimal(101)iscalledunder-unincolloquialoctal.

ApplicationinComputers

Octaliswidelyusedincomputersystems,suchasPDP-8,ICL1900andIBMmainframesusing12-bit,24-bitor36-bit.Theoctalsystemisthebasisforthese,becausetheiridealbinarywordabbreviationsizecanbedivisibleby3(eachoctaldigitrepresentsthreebinarydigits).Four,eighttotwelvenumberscanshowtheentiremachineconcisely.Italsoreducescostssothatnumberscanbeusedintheoperatorconsolethroughnixietubes,seven-segmentdisplays,andcalculators.Theyaretoocomplicatedtouseinbinarydisplay.However,decimaldisplayrequirescomplicatedhardware,andhexadecimaldisplayneedstodisplaymorenumber.

However,allmoderncomputingplatformsuse16-32bits,or64bits.If64bitsareused,theywillbefurtherdividedintooctets.Inthissystem,threeoctaldigitscanmeettheneedsofeachbyte,andthemostimportantoctaldigitrepresentstwobinarydigits(+1isthenextbyte,ifany).Theoctalrepresentationofa16-bitwordrequires6digits,butthemostimportantoctaldigitrepresents(passes)onlyone(0or1).Thismeansthataneasy-to-readbytecannotbeprovidedbecauseitisa4-digitoctalnumber.

Therefore,hexadecimalisthemorecommonlyusedprogramminglanguagetoday,becausetwohexadecimaldigitscompletelyspecifyonebyte.Onsomeplatforms,thepowerof2,wordsizeandinstructionsareeasiertounderstand.Themodernubiquitousx86architecturealsobelongstothiscategory,butthisarchitectureisrarelyusedinoctal,althoughthebinaryencodingoftheopcodeofcertainattributesbecomesmoreobvious.Whendisplayedinoctal,suchasModRMbytes,itisdividedintoItis2,3,and3bits,sooctalcanbeusedtodescribethesecodes.

Octalissometimesusedincalculationsinsteadofhexadecimal,andperhapsmostofteninmodernUnixsystemswithfilepermissions.Itsadvantageisthatitdoesnotrequireanyadditionalsymboldigits(thehexadecimalsystemisbase16,soitrequiressixadditionalsymbolsbeyond0-9).Itisallusedfordigitaldisplay.

Inprogramminglanguages,octalliteralsareusuallycombinedwithdifferentprefixes,includingdigit0,letteroorq,digit-letter0o,orsymbol&[11]ordollar.InMotorolaconvention,octalnumbersareprefixedwith@,andthesmallletteroisaddedasasuffix,inIntelconvention.DR-DOSdebuggingusesprefixestoeditoctalnumbers.

Forexample,thecharacter73(octal)canbeexpressedas073,o73,q73,0o73,\73,@73,&73,$73or73oinvariouslanguages.

Thenewlanguagehasabandonedtheprefix0,anddecimalsareoftenrepresentedbyleadingzeros.Avoidtheprefixobeingmistakenforzero,andtheprefix0begantointroduceotoavoidnumericaltextwithEnglishletters(suchasoorq),becausethesemaycausethetexttoconfusethevariablename.Theprefix0oalsofollowstheprefix0xsetbythemodelforthehexadecimalcharacterClanguage;itsupportsHaskell,OCaml,Perl6,Python3.0version,Ruby,Tclversion9,anditspurposeistosupportECMAScript6.(Theprefix0hasbeendeprecatedinECMAScript3andECMAScript5[21]).

Octalnumbersareusedinsomeprogramminglanguages​​(C,Perl,PostScript...)torepresentbytestringsintext/graphicrepresentationsasbytevalues​​(acodepagerepresentsnon-graphics,inthecurrentcontextSpecialmeaning.

Conversion

Themutualconversionbetweenbinaryandoctalissimilartotheconversionbetweenbinaryandhexadecimal.Thedifferenceisthatthreedigitsarerequiredinsteadoffourdigits.Table2-2liststheequivalentrepresentationsofbinaryandoctal.

Inordertoconvertanoctalnumbertobinary,replaceeachoctaldigitwiththecorrespondingthreedigitsinTable2-2.Forexample,octalTheresultofconverting123intobinaryis001010011:

1Octal

2

3

001

010

011

tr>
Table2-2Binary/octalconversiontable

Binary

octal

000

0

001

1

010

2

011

3

100

4

101

5

110

6

111

7

InordertoconvertabinarynumbertoForoctal,justdividethebinarystringintogroupsofthreedigits(ifnecessary,addzerosinthefront),thenlookupTable2-2,andreplacethethree-digitstringwiththecorrespondingoctaldigits.

Ifyouneedtoconvertanoctalnumbertohexadecimal,justconverttheoctalnumbertobinary,andthenconverttohexadecimal.

Convertoctaltodecimal

Example:Convertoctalnumber12todecimalnumber

octalConvertedtoBinary

Rules:Inaccordancewiththeorder,every1-digitoctalnumberisrewrittenintoanequivalent3-digitbinarynumber,andtheorderremainsthesame.

Example:(17.36)8=(001111.011110)2=(1111.01111)2

Octaltohexadecimal

FirstTheoctalisconvertedtobinary,andthenthebinaryisconvertedtohexadecimal.

Example:(712)8=(111001010)2=(1CA)16

Converttooctal

Binarytooctal

Theintegerpartstartswiththeleastsignificantdigit,andisagroupof3digits.Whenthemostsignificantdigitislessthan3digits,itisfilledwith0.Eachgroupcanbeconvertedintoanoctalvalue.Aftertheconversion,itisanoctalinteger.

Thefractionalpartstartswiththemostsignificantdigit,andagroupof3digits.Iftheleastsignificantdigitislessthan3digits,itisfilledwith0.Eachgroupcanbeconvertedintoanoctalvalue.Aftertheconversioniscompleted,itisoctal.Ofdecimals.

Example:(11001111.01111)2=(011001111.011110)2=(317.36)8

Hexadecimaltooctal

Firstuse1Inthe4method,thehexadecimalnumberisconvertedtobinary;thenthe3and1methodisusedtoconvertthebinaryto8system.

Example:(1CA)16=(111001010)2=(712)8

Note:Thehighzerobeforethedecimalpointandthelowzeroafterthedecimalpointcanberemoved.

Decimaltooctal

Method1:Divideby8andtaketheremaindermethod.

Example:Convertthedecimalnumber115intoanoctalnumber

8|115……3

8|14……6

8|1……1

Result:(115)10=(163)8

Method2:FirstadoptThemethodofturningbinaryintodecimal,thenturningbinarydigitintooctalnumber

Example:(115)10=(1110011)2=(163)8

ExpressioninClanguage

InClanguage,therearethreerepresentationsofintegers:decimal,octal,andhexadecimal.Whichstartswiththenumber0,andthenumbercomposedof0~7isoctal.Itstartswith0Xor0xandiscomposedof0~9,A~Fora~finhexadecimal.Exceptforthesignsthatindicatepositiveandnegative,itstartswith1~9andiscomposedof0~9indecimal.

1.Decimal:Exceptforsignsthatindicatepositiveandnegative,itstartswith1~9andconsistsof0~9.Suchas128,+234,-278.

2,octal:anumberstartingwith0andconsistingof0~7.Suchas0126,050000.

3,Hexadecimal:Startwith0Xor0x,andconsistof0~9,A~Fora~f.Suchas0x12A,0x5a000.

Related Articles
TOP