Questions tagged [signed-integer]

71 questions
0
votes
1 answer

Adding to unsigned and signed binary integers

I was wondering if someone can explain to me what happens when we add binary numbers. Say we have 4 bits, 0b1111 and we add 1 to 0b1111. I think the binary encoding should be 0b10000; however, since there are only 4 bits the bits will change to…
Engah
  • 35
  • 2
  • 8
0
votes
2 answers

Binary to 16 Bit unsigned & 16 bit signed magnitude

I missed a day of class due to illness, so I checked out my profs. material for that day online and I'm stuck on this. His notes don't have an explanation on how to do it. I can do conversions between the masses (decimal to octal, hex, binary etc.),…
Saigo no Akuma
  • 147
  • 1
  • 1
  • 11
0
votes
2 answers

Change the width of a signed integer to a nonstandard width

For a networking application I need a signed, 2's complement integer. With a custom width. Specified at run time. Assuming the value of the integer falls in the width. The problem I have is the parity bit. Is there any way of avoid having to…
laurisvr
  • 2,724
  • 6
  • 25
  • 44
-1
votes
1 answer

How to subtract negative numbers from negative numbers using Complement notation?

I've just started learning. I am trying to understand this thoroughly and deeply. I somewhat understand it as long as it's subtraction between a Smaller number from a Larger number or a Larger number from a Smaller number, but when the Minuend in…
-1
votes
1 answer

Convert normal integer to 8 bit integer in PHP

I have an Integer 138 that i want to covert into an 8 bit signed Integer that will become -118. I have tried unpack, intval and several othe php function but they didn't worked. How should i do this, stuck in this for few days now.
-1
votes
4 answers

Not getting Integer Overflow

Say I want to print some values. I am assuming that I should get Integer Overflow if my signed variable exceeds from TMin and TMax (in this case, using 4 byte int, 0x7FFFFFFF as Tmax and 0x80000000 as Tmin) but in these example I am not getting what…
Yar
  • 7,020
  • 11
  • 49
  • 69
-2
votes
2 answers

Why is int i = 1<<31 == -2147483648 instead of 2147483648?

I was trying to understand the bitwise operation and according to me integer contains 32 bit and from LSB 0th position to MSB 31st position so if I set left shift 1 to 31 place I think I should get 2^31 and the binary representation of it would be…
-3
votes
1 answer

Code generator in MIPS assembly

Anybody who knows how to translate this pseudocode into MIPS assembly? Seed is a global variable FUNCTION codgen(): UNSIGNED INTEGER; LOCAL SIGNED INTERGER n; LOCAL UNSIGNED INTEGER x,y; BEGIN n:= [right-justify the five bits "seed"<24:20>, and…
-3
votes
1 answer

Sorting between signed and unsigned zeros c++

I have to be able to sort negative zeros and zeros for an assignment i am doing at university using c++, could someone tell me why the following code does produce a negative zero? i'm stuck and i am not sure why this works... cout << "Enter…
Ryan
  • 51
  • 1
  • 4
-4
votes
1 answer

How does sign contraction work from 16 bit to 8 bit?

How do I sign contract ff12.here it is a negative number but I need to remove all the FF here but if I do that it becomes a positive number. One definition of "sign contraction" can be found in this online copy of The Art of Assembly, as the…
-5
votes
2 answers

How to printf a sint32 in C using gcc compiler tricore v3.4.6?

I am working with the tricore v3.4.6 compiler. Suppose I have a signed integer like sint32 a = -1 and want to print that with printf. I tried printf("Signed number %i", a) as well as printf("Signed number %d", a) which both gives me compiler…
floquet22
  • 323
  • 2
  • 15
1 2 3 4
5