signed


converting signed 255 into 8-bit twos complement


I need to convert a signed decimal number (255) into 8-bit two's complement for a HW problem.
My problem is that I'm not sure how to make a number like 255 positive with 8-bits, because I believe the range is -128 to 127, correct?
If 01111111 is 127, then how can I get 255 into binary with just 8 bits.
I think I just don't understand if "signed" is only referring to the decimal number or if it also refers to the binary number.
A signed value of 255 would have to - at minimum - be represented in 9 bits.
0...11111111 = +225
Given an 8 bit representation, you are correct, we can represent only up to +127/-128.
Were we to cast signed 255 to an 8 bit field, we'd lose the semantic meaning of the first bit, leaving us with 11111111 representing -1 (though potentially -0, depending on our implementation).
Attempting to take the two's complement of this value would yield:
11111111
00000000 (flip bits)
00000001 (add one)
= 1 (integer value)
Like I said in the comment, this looks to me like a question I would have been asked to query my understanding of that signed bit and it consuming a bit of numeric representation, which you seem to have figured out already.
I'm definitely not an expert in this sort of stuff but are you sure you have the question correct?
Surely signed refers to the binary number only?
In 8bit stands for byte and it is unsigned and and the range that covers is from 0 to 255
so 255 decimal should be 11111111 in 8bit
Signed means that negative number are also allowed if you have to cover the range from -255 to 255 you can put the negative number in one byte and the positves in the other byte

Related Links

anyone know a signed kext will expire(not working) after Apple Developer membership expires?
converting signed 255 into 8-bit twos complement
Converting from 8 bit to 16 bit
Exception connecting to SQL Server CE 4.0

Categories

HOME
hpoo
office365
artificial-intelligence
user-interface
protocol-buffers
class
tomcat
functional-programming
postgresql-9.4
nsview
dronekit-python
turbojpeg
azure-mobile-services
repair
javafx-8
sympy
telegraf
clickable-image
match
clish
spring-amqp
jaspersoft-studio
scheduled-tasks
bazaar
infrared
libgit2
batch-rename
spreadsheetgear
bonita
javax.persistence
es6-modules
custom-keyboard
ms-dos
mv
praat
jacoco-maven-plugin
icepdf
angular-datatables
haar-classifier
spooler
httphandler
virtual-memory
head.js
renderman
maven-jaxb2-plugin
mura
pen
.when
maatwebsite-excel
pbx
s-function
clp
zynq
perforce-integrate
qpixmap
vimperator
ioctl
gdl
json-spirit
smart-tv
openshift-cartridge
vdm-sl
cache-manifest
camus
mutators
maven-shade-plugin
sql-processor
screwturn
forceclose
meteor-collections
jomsocial
sql-view
codahale-metrics
hints
oscilloscope
android-authenticator
icenium
ip-geolocation
uitextfielddelegate
algol68
type-safety
filelock
getopts
database-deadlocks
directshow.net
mongrel
jdownloader
ccnet-config
odac
getimagesize
rtti
parentid

Resources

Encrypt Message