Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

binary - Is two's complement notation of a positive number the same number?

Is two's complement notation of a positive number is same as its binary representation?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Some of the answers and comments are getting the relationship between a "two's complement notation" and the "two's complement of a number" confused. The question may need to be clarified a bit, but it is clearly asking about "two's complement notation."

Two's complement notation includes both positive and negative numbers. Binary numbers can mean lots of things, so in order to determine what any binary number is supposed to represent, one must first know what notation or encoding is being used. The binary number could be an unsigned integer, two's complement integer, an IEEE floating point number, a string of characters, or something else entirely.

So 7 in two's complement notation is 00000111, just as it is as an unsigned integer. And -7 in two's complement notation is 11111001.

So, yes, positive integers in two's complement notation are represented the same way they are with unsigned integers (assuming it is a valid integer for the number of bits being used).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...