欢迎来到天天文库
浏览记录
ID:41287374
大小:170.00 KB
页数:13页
时间:2019-08-21
《数字逻辑2-2n》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Chapter2NumbersystemsandcodesDecimalandBinaryUnsignedandSignedCodeforNumbersandCharactersRepresentationsofsignednumbersInbinarysystems,ann-bitstringcanonlyrepresent2ndifferentnumbers!Unsigned:0—2n-1signed:-(2n-1-1)—2n-1-1Torepresent2ndifferentnumbersa
2、ndtheirnegativepart,wehavetousen+1bits!MSBisnotavaluebit,butasignbit:Negative:1Positive:0RepresentationsofsignednumbersSigned-magnitudecode(S-Mcode):reversal!One’scomplementcode:shift!Two’scomplementcode:shift!RepresentationsofsignednumbersConvertingr
3、ulesforsignednumbersFromunsignedtosigned:ItsMSBischangedtosignbit.Thenumbermustbeapositive!Bewaretheoverflow!Keypoint:Apositivesignednumberwithanycodemustbethesame!ItsMSBis“0”!Changethesignofasignednumbersigned-magnitude:changethesign-bit;+21:00010101
4、-21:10010101one’scomplement:changeeverybit;+21:00010101-21:11101010two’scomplement:changeeverybit,andadd1atLSB;+21:00010101-21:11101011FromonecodetoanotherStep1:ChecktheMSB(sign-bit);Forpositivenumber(MSB=0):nochanges!Step2:Fornegativenumber(MSB=1):fi
5、rstchangeitssignbytheformercodeway;thenchangeitssignbythenextcodeway!Examples:FromonecodetoanotherAdditionforsignednumbersUseadditionrulesforunsignednumbers,onlyTwo’scodecangetrightresult!twonumbersmustbethesamewidth,andkeepthewidthinaddition!subtract
6、anumbermeansaddthenegativenumber;Examples:1110+1010=10000110–0011=0110+1101=0011AdditionforsignednumbersOverflow:theresultexceedsthenumberranges;condition:twonumbershasthesamesign;checking:thesigniswrong!solving:increasethedatawidth!Examples:0101+0101
7、=10101101+1010=0111AdditionforsignednumbersS-M:add0bitafterthesigned-bit(MSB);Others:addsigned-bitbeforeMSB;Examples:S-M:0101=>000001011100=>10000100OTHERS:0101=>000001011100=>11111100HowtoincreasethenumberwidthMultiplicationforsignednumbersOnlyS-M’sc
8、odecanbeeasydone!Thesign-bitoftheresultistheXORofthesign-bitsoftheinputs!Thevalue-bitsoftheresultisdecidedbythemultiplicationrulesfortheunsignednumbers!
此文档下载收益归作者所有