Are negative signed integers, converted to binary, simply regular integers +256?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Are negative signed integers, converted to binary, simply regular negative integers +256?



00001010 = + 10 signed
00001010 = + 10 unsigned

11110110 = - 10 signed
11110110 = +246 unsigned (-10+256=246)


Notice how -10 (signed) is just -10+256=246 (unsigned)?



So in other words: If you want to represent a negative integer (such as -10) as a signed byte, you would simply add 256 before doing the base2 conversion?



I also heard that it can be done by "inverting all the bits and then adding one to the result".




PS: If it's not obvious, dealing with numbers isn't a strength of mine. I know that's probably not the case for most of you, but I'm trying to simplify the concept. Please keep that in mind, and if possible (respectfully) try to resist the urge to make it more confusing or complicated.







share|cite|improve this question

















  • 2




    There are different systems in use. E.g Two's complement and Ones' complement .
    – mvw
    Jul 15 at 15:41







  • 2




    Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
    – Hagen von Eitzen
    Jul 15 at 15:45










  • A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
    – hardmath
    Jul 15 at 15:48










  • I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
    – tjt263
    Jul 15 at 15:49










  • You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
    – David K
    Jul 15 at 16:36














up vote
0
down vote

favorite












Are negative signed integers, converted to binary, simply regular negative integers +256?



00001010 = + 10 signed
00001010 = + 10 unsigned

11110110 = - 10 signed
11110110 = +246 unsigned (-10+256=246)


Notice how -10 (signed) is just -10+256=246 (unsigned)?



So in other words: If you want to represent a negative integer (such as -10) as a signed byte, you would simply add 256 before doing the base2 conversion?



I also heard that it can be done by "inverting all the bits and then adding one to the result".




PS: If it's not obvious, dealing with numbers isn't a strength of mine. I know that's probably not the case for most of you, but I'm trying to simplify the concept. Please keep that in mind, and if possible (respectfully) try to resist the urge to make it more confusing or complicated.







share|cite|improve this question

















  • 2




    There are different systems in use. E.g Two's complement and Ones' complement .
    – mvw
    Jul 15 at 15:41







  • 2




    Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
    – Hagen von Eitzen
    Jul 15 at 15:45










  • A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
    – hardmath
    Jul 15 at 15:48










  • I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
    – tjt263
    Jul 15 at 15:49










  • You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
    – David K
    Jul 15 at 16:36












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Are negative signed integers, converted to binary, simply regular negative integers +256?



00001010 = + 10 signed
00001010 = + 10 unsigned

11110110 = - 10 signed
11110110 = +246 unsigned (-10+256=246)


Notice how -10 (signed) is just -10+256=246 (unsigned)?



So in other words: If you want to represent a negative integer (such as -10) as a signed byte, you would simply add 256 before doing the base2 conversion?



I also heard that it can be done by "inverting all the bits and then adding one to the result".




PS: If it's not obvious, dealing with numbers isn't a strength of mine. I know that's probably not the case for most of you, but I'm trying to simplify the concept. Please keep that in mind, and if possible (respectfully) try to resist the urge to make it more confusing or complicated.







share|cite|improve this question













Are negative signed integers, converted to binary, simply regular negative integers +256?



00001010 = + 10 signed
00001010 = + 10 unsigned

11110110 = - 10 signed
11110110 = +246 unsigned (-10+256=246)


Notice how -10 (signed) is just -10+256=246 (unsigned)?



So in other words: If you want to represent a negative integer (such as -10) as a signed byte, you would simply add 256 before doing the base2 conversion?



I also heard that it can be done by "inverting all the bits and then adding one to the result".




PS: If it's not obvious, dealing with numbers isn't a strength of mine. I know that's probably not the case for most of you, but I'm trying to simplify the concept. Please keep that in mind, and if possible (respectfully) try to resist the urge to make it more confusing or complicated.









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 15 at 16:06
























asked Jul 15 at 15:39









tjt263

1094




1094







  • 2




    There are different systems in use. E.g Two's complement and Ones' complement .
    – mvw
    Jul 15 at 15:41







  • 2




    Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
    – Hagen von Eitzen
    Jul 15 at 15:45










  • A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
    – hardmath
    Jul 15 at 15:48










  • I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
    – tjt263
    Jul 15 at 15:49










  • You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
    – David K
    Jul 15 at 16:36












  • 2




    There are different systems in use. E.g Two's complement and Ones' complement .
    – mvw
    Jul 15 at 15:41







  • 2




    Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
    – Hagen von Eitzen
    Jul 15 at 15:45










  • A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
    – hardmath
    Jul 15 at 15:48










  • I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
    – tjt263
    Jul 15 at 15:49










  • You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
    – David K
    Jul 15 at 16:36







2




2




There are different systems in use. E.g Two's complement and Ones' complement .
– mvw
Jul 15 at 15:41





There are different systems in use. E.g Two's complement and Ones' complement .
– mvw
Jul 15 at 15:41





2




2




Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
– Hagen von Eitzen
Jul 15 at 15:45




Actually, for an integer (as opposed to signed char), you may have to add $4294967296$ or even $18446744073709551616$ instead of $256$ :)
– Hagen von Eitzen
Jul 15 at 15:45












A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
– hardmath
Jul 15 at 15:48




A microprocessor manual will necessarily illustrate the format for signed integers (of varying "sizes"). Your magic constant 256 suggests you are thinking of signed bytes, but you should be aware that default integers are bigger than that on modern CPUs.
– hardmath
Jul 15 at 15:48












I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
– tjt263
Jul 15 at 15:49




I think this would be two's complement. I'm not familar with any other. I tried to add a two's complement tag, but there wasn't one.
– tjt263
Jul 15 at 15:49












You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
– David K
Jul 15 at 16:36




You can put "two's complement" in the search box on a MSE web page and get a list of mostly-relevant questions and answers.
– David K
Jul 15 at 16:36










1 Answer
1






active

oldest

votes

















up vote
1
down vote













That works for $8-$bit signed integers on a twos' complement machine. General-purpose computers all use twos' complement these days, but there are programmable logic arrays that use sign-magnitude. If you are using a high-level language like C, don't do this yourself, but let the compiler take care of it, because it will work differently for different-sized integer types. If you are using a language with unlimited sized integers, like python, this system doesn't work at all.






share|cite|improve this answer





















  • I don't know anything about that, let's just stick with two's complement for now.
    – tjt263
    Jul 15 at 16:44










  • @tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
    – saulspatz
    Jul 15 at 16:47










  • This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
    – tjt263
    Jul 15 at 16:59










  • @tjt263 In that context, adding $256$ is correct.
    – saulspatz
    Jul 15 at 17:01










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2852629%2fare-negative-signed-integers-converted-to-binary-simply-regular-integers-256%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













That works for $8-$bit signed integers on a twos' complement machine. General-purpose computers all use twos' complement these days, but there are programmable logic arrays that use sign-magnitude. If you are using a high-level language like C, don't do this yourself, but let the compiler take care of it, because it will work differently for different-sized integer types. If you are using a language with unlimited sized integers, like python, this system doesn't work at all.






share|cite|improve this answer





















  • I don't know anything about that, let's just stick with two's complement for now.
    – tjt263
    Jul 15 at 16:44










  • @tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
    – saulspatz
    Jul 15 at 16:47










  • This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
    – tjt263
    Jul 15 at 16:59










  • @tjt263 In that context, adding $256$ is correct.
    – saulspatz
    Jul 15 at 17:01














up vote
1
down vote













That works for $8-$bit signed integers on a twos' complement machine. General-purpose computers all use twos' complement these days, but there are programmable logic arrays that use sign-magnitude. If you are using a high-level language like C, don't do this yourself, but let the compiler take care of it, because it will work differently for different-sized integer types. If you are using a language with unlimited sized integers, like python, this system doesn't work at all.






share|cite|improve this answer





















  • I don't know anything about that, let's just stick with two's complement for now.
    – tjt263
    Jul 15 at 16:44










  • @tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
    – saulspatz
    Jul 15 at 16:47










  • This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
    – tjt263
    Jul 15 at 16:59










  • @tjt263 In that context, adding $256$ is correct.
    – saulspatz
    Jul 15 at 17:01












up vote
1
down vote










up vote
1
down vote









That works for $8-$bit signed integers on a twos' complement machine. General-purpose computers all use twos' complement these days, but there are programmable logic arrays that use sign-magnitude. If you are using a high-level language like C, don't do this yourself, but let the compiler take care of it, because it will work differently for different-sized integer types. If you are using a language with unlimited sized integers, like python, this system doesn't work at all.






share|cite|improve this answer













That works for $8-$bit signed integers on a twos' complement machine. General-purpose computers all use twos' complement these days, but there are programmable logic arrays that use sign-magnitude. If you are using a high-level language like C, don't do this yourself, but let the compiler take care of it, because it will work differently for different-sized integer types. If you are using a language with unlimited sized integers, like python, this system doesn't work at all.







share|cite|improve this answer













share|cite|improve this answer



share|cite|improve this answer











answered Jul 15 at 15:49









saulspatz

10.7k21323




10.7k21323











  • I don't know anything about that, let's just stick with two's complement for now.
    – tjt263
    Jul 15 at 16:44










  • @tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
    – saulspatz
    Jul 15 at 16:47










  • This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
    – tjt263
    Jul 15 at 16:59










  • @tjt263 In that context, adding $256$ is correct.
    – saulspatz
    Jul 15 at 17:01
















  • I don't know anything about that, let's just stick with two's complement for now.
    – tjt263
    Jul 15 at 16:44










  • @tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
    – saulspatz
    Jul 15 at 16:47










  • This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
    – tjt263
    Jul 15 at 16:59










  • @tjt263 In that context, adding $256$ is correct.
    – saulspatz
    Jul 15 at 17:01















I don't know anything about that, let's just stick with two's complement for now.
– tjt263
Jul 15 at 16:44




I don't know anything about that, let's just stick with two's complement for now.
– tjt263
Jul 15 at 16:44












@tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
– saulspatz
Jul 15 at 16:47




@tjt263 Well, everything but the remark on sign-magnitude is relevant to twos' complement.
– saulspatz
Jul 15 at 16:47












This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
– tjt263
Jul 15 at 16:59




This isn't really for any particular scenario. I had an exam, and there were some questions I couldn't answer. They were simple conversion and questions. Some involved addition, etc.
– tjt263
Jul 15 at 16:59












@tjt263 In that context, adding $256$ is correct.
– saulspatz
Jul 15 at 17:01




@tjt263 In that context, adding $256$ is correct.
– saulspatz
Jul 15 at 17:01












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2852629%2fare-negative-signed-integers-converted-to-binary-simply-regular-integers-256%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?