Hi, I'm having trouble trying to figure out a code that converts negative decimal numbers to binary, as well as specifying the number of bits. For example. convert -18 using 8 bits. This should come out as 10010010 doing it manually, I think. I'd appreciate the help, thanks.
ALJ
0
Newbie Poster
Recommended Answers
Jump to PostWorking with negative numbers in binary you need to use twos complement method. It is a bit confusing to start with (well it was for me). I use it a lot for checksum calculations. Hope this helps.
http://www.rsu.edu/faculty/PMacpherson/Programs/twos.html
David
Jump to PostHi, I'm having trouble trying to figure out a code that converts negative decimal numbers to binary, as well as specifying the number of bits. For example. convert -18 using 8 bits. This should come out as 10010010 doing it manually, I think. I'd appreciate the help, thanks.
This may …
All 8 Replies
davidjhay
0
Newbie Poster
jai.mahadeokar
0
Newbie Poster
bumsfeld
413
Nearly a Posting Virtuoso
Pierre Maurette
0
Newbie Poster
jrcagle
77
Practically a Master Poster
jrcagle
77
Practically a Master Poster
Jason43
0
Newbie Poster
klickagent
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.