Countingsystem
Base
Thecountingsystematthebaseb(wherebisApositivenaturalnumberiscalledabase),andbbasicsymbols(ornumbers)correspondtothesmallestbnaturalnumbersincluding0.Togenerateothernumbers,thepositionofthesymbolinthenumbermustbeused.Thesymbolofthelastdigitusesitsownvalue,andthevalueofonedigittotheleftismultipliedbyb.Generallyspeaking,ifbisthebase,weexpressthenumberinthebbasesystemintheformof,andwritethenumbersinordera0a1a2a3...ak.Thesenumbersarenaturalnumbersfrom0tob-1.
Generallyspeaking,thenumberinthebhexadecimalsystemhasthefollowingform:
NumberAndaretheproportionsofthecorrespondingnumbers.
Binarycounting
TheGermanmathematicianLeibnizfromthe17thtothe18thcenturywasthefirstpersonintheworldtoproposethebinarynotation.Usebinarynotation,onlyusethetwosymbolsof0and1,noothersymbolsareneeded.
Binarydataalsoadoptsthepositioncountingmethod,anditspositionweightisapowerof2asthebase.Forexample,thebinarydata110.11,every2enters1,theweightorderis2²,2¹,2º,,.Forbinarydatawithn-digitintegersandm-digitdecimals,expressedasaweightedcoefficientexpansion,itcanbewrittenas:
Binarydatacangenerallybewrittenas:
[Example]:Writethebinarydata111.01intheformofweightingcoefficient.
Solution:
Binary,hexadecimal,andoctalarethesame,andtheyareallcarriedinthepoweroftwo.
Operation
Addition
Therearefourcasesofbinaryaddition:0+0=0,0+1=1,1+0=1,1+1=10(0isroundedto1).
Multiplication
Therearefourcasesofbinarymultiplication:0×0=0,1×0=0,0×1=0,1×1=1.
Subtraction
Therearefourcasesofbinarysubtraction:0-0=0,1-0=1,1-1=0,0-1=1.
Division
Therearetwocasesofbinarydivision(thedivisorcanonlybe1):0÷1=0,1÷1=1.
Example
Thearithmeticoperationoftwobinarynumbers1001and0101canbeexpressedas:
Binaryconversion
Binaryconversiontodecimal
Method:"Expandsumbyweight".Thespecificstepsofthismethodaretofirstwritebinarynumbersasweightedcoefficientexpansions,andthensumthemaccordingtotheadditionrulesofthedecimalsystem.
[Example]:
Rule:Thenumberofdigitsintheonesplaceis0,thenumberoftens'digitsis1,......,increasingsequentially,andthenumberofdigitsinthetenthplaceis-1,andthenumberofdigitsinthepercentileis-2,...,indescendingorder.
Convertingdecimaltobinary
Adecimalnumberisconvertedtoabinarynumbertobeconvertedintointegerpartanddecimalpartseparately,andfinallycombinedtogether.
Theintegerpartadoptsthemethodof"divideby2andtaketheremainder,arrangeinreverseorder".Thespecificmethodis:Dividethedecimalintegerby2togetaquotientandremainder;thendividethequotientby2togetaquotientandremainder.Continuethiswayuntilthequotientislessthan1,andthenusethefirstobtainedremainderasbinaryThelow-significantdigitsofthenumber,andtheremainderobtainedasthehigh-significantdigitsofthebinarynumber,arearrangedinsequence.Example:125.
Thedecimalpartshouldusethe"multiplyby2roundingmethod".Thatis,multiplythedecimalfractionby2andtakeawaytheintegeroftheresult(itmustbe0or1),andthenrepeatthepreviousstepswiththeremainingdecimalsuntiltheremainingdecimalsare0andstop,andfinallytheintegersobtainedeachtimeThepartsarearrangedinorderfromlefttorighttogetthecorrespondingbinarydecimal.Forexample,theprocessofconvertingadecimaldecimalnumber0.8125intoabinarydecimalnumberisasfollows:
Universalhexadecimalconversion
Theessenceofconversionbetweendifferenthexadecimalsistodeterminethedigitsatdifferentweightpositions.Thereisasimplealgorithmforconvertingthebaseofapositiveinteger,thatis,byusingthetargetbaseforlongdivision;theremaindergivesthe"number"startingfromthelowestdigit.Forexample,1020304fromdecimalto7:
Anotherexample,10110111from2to5:
Thereasonwhythecomputerusesbinary
Firstofall,thebinarysystemusesonlytwodigits.0and1,soanyelementwithtwodifferentstablestatescanbeusedtorepresentacertaindigitofanumber.Infact,therearemanycomponentswithtwoobviousstablestates.Forexample,the"on"and"off"oftheneonlamp;the"on"and"off"oftheswitch;the"high"and"low","positive"and"negative"ofthevoltage;the"holes"and"Nohole";"signal"and"nosignal"inthecircuit;thesouthandnorthpolesofmagneticmaterials,etc.,tonameafew.Itiseasytousethesedistinctstatestorepresentnumbers.Notonlythat,butmoreimportantly,thetwocompletelydifferentstatesarenotonlyquantitativelydifferent,butalsoqualitativelydifferent.Inthisway,theanti-interferenceabilityofthemachinecanbegreatlyimproved,andthereliabilitycanbeimproved.Itismuchmoredifficulttofindasimpleandreliabledevicethatcanexpressmorethantwostates.
Secondly,thefourarithmeticrulesofthebinarycountingsystemareverysimple.Inaddition,thefourarithmeticoperationscanbesummedupasadditionoperationsandshifts.Inthisway,thearithmeticcircuitintheelectroniccomputerbecomesverysimple.Notonlythat,thelineissimplified,andthespeedcanbeincreased.Thisisalsoincomparablewiththedecimalcountingsystem.
Third,theuseofbinaryrepresentationinelectroniccomputerscansaveequipment.Itcanbeprovedtheoreticallythatthethree-digitsystemsavesthemostequipment,followedbythebinarysystem.However,becausethebinarysystemhasadvantagesthatothercarrysystems,includingtheternarysystem,donothave,mostelectroniccomputersstillusebinarysystems.Inaddition,sinceonlytwosymbols"0"and"1"areusedinthebinarysystem,Booleanalgebracanbeusedtoanalyzeandsynthesizethelogiccircuitsinthemachine.Thisprovidesaveryusefultoolfordesigningelectroniccomputercircuits.
Fourth,thebinarysymbols"1"and"0"correspondtothe"true"and"false"(false)inlogicaloperations,whichisconvenientforcomputerstoperformlogicaloperations.