Questions tagged [signed-integer]
71 questions
0
votes
1 answer
Unsigned Multiplication using Signed Multiplier
I have been assigned with a task to perform unsigned multiplication using signed multiplier. Despite multiple attempts, I couldn't get it. Is it possible to do this?
Code:
#include
int main()
{
// Must be short int
short int…

fatalcoder524
- 1,428
- 1
- 7
- 16
0
votes
0 answers
C# Masking a signed int with a hex mask that "looks like" UInt
I have a problem with masking an Int16, C# interprets the mask's high hex number (65532d) as an Int32.
I have seen many examples but they have either UInt or use friendly sunshine low-bit masks that don't interfere with the sign bit so no…

P Oltergeist
- 44
- 6
0
votes
2 answers
Is the two's complement of a negative integer used only for addition and subtraction?
So for example,
13 in binary is: 00000000 00000000 00000000 00001101.
Would -13 be stored as 10000000 00000000 00000000 00001101 (using the most significant bit to represent the sign) or would it be stored using the two's complement? (Specifically…

Taseen A
- 49
- 5
0
votes
0 answers
How to drop '+' or '-' characters in MASM Assembly
In MASM Assembly, if the user writes "-22", I want to check the first character for a "-" sign and then drop it.
If the user writes "+12", I want to check the first character for a "+" sign and then drop it.
The code below is not working.
Could…

halpme
- 17
- 3
0
votes
0 answers
Java convert from signed to unsigned in a single byte
I have a byte b that in Java represents signed integers from -128 to +127. How do I convert it to represent only (positive) unsigned integers? I don't want to use int or long but a 1-byte representation and simply shift the bits in b

raff5184
- 344
- 1
- 2
- 15
0
votes
0 answers
Convert HEX to Signed INT Javascript
I am trying to convert this HEX value fba46c58 to a signed int then take that number and divide it by 1000000. I have tried the following code but I don't seem to come up with the correct number. Overall I need the end number to equal…

gregwinn
- 941
- 1
- 9
- 16
0
votes
1 answer
Hashing int16_t to uint64_t
I'm trying to make a hash function for int16_t. The function prototype looks like this:
uint64_t hash_int16_t(const void *key);
So far I've gotten this but I don't know if this is the correct approach:
uint64_t hash_int16_t(const void *key)
{
…
user8298902
0
votes
1 answer
What are the specifics of STORING a 32 bit signed integer into a register?
My number type is a signed two’s complement integer.
In memory registers %rdi/edi/di, I have 0xFFFFFFFF.
In %rsi/esi/si, I have 0x80000000.
My instruction is addl %edi, %esi.
How do I properly add these?
I think the answer is:
Since I'm adding the…

The_Senate
- 149
- 6
0
votes
3 answers
What does actually mean by the statement "PHP does not support unsigned integers"?
I am using PHP 7.0.2
At one place in the manual on integers, I saw the below statement :
Integers can be specified in decimal (base 10), hexadecimal (base 16),
octal (base 8) or binary (base 2) notation, optionally preceded by a
sign (- or…

PHPLover
- 1
- 51
- 158
- 311
0
votes
1 answer
Reading a fortran generated binary file into a signed integer array in C++
I am learning C++. I want to read some files generated by a fortran program in a C++ program. Each of the files I want to read contains a list of numbers which are either 0, 1, or -1. These numbers are the elements of an array of 1-byte integers…

Harinder Pal
- 1
- 3
0
votes
3 answers
Convert binary to signed int/decimal
I am trying to convert hex data to signed int/decimal and can't figure out what I'm doing wrong.
I need FE to turn into -2.
I'm using Convert.ToInt32(fields[10], 16) but am getting 254 instead of -2.
Any assistance would be greatly appreciated.

StarScr3am77
- 25
- 4
0
votes
1 answer
How to convert NSString with negative integer into negative integer
In my app, I want to display 0 if NSString contains negative integers. I tried to convert NSString into signed int but my NSString to signed int conversion code always returns 0 value.
Eg: I want to convert @"-0.02" into -0.02 int. But my code…

Kirti Nikam
- 2,166
- 2
- 22
- 43
0
votes
4 answers
Largest positive value of a signed integer type of unknown size
If we have a unsigned integer type which we may not know the size of, for example size_t, then we can get the largest value it can hold relatively simply with something like:
size_t maximal = -1;
Is there a similar technique for a signed integer…

John Hascall
- 9,176
- 6
- 48
- 72
0
votes
1 answer
Unsigned -1 = signed -1
Quite a few similar questions have been asked, but it still baffles me how
unsigned int a = -1;
int b = ~0;
if (a == b)
printf("%u\t%d", a, b);
returns
4294967295 -1
I understand how the values are stored in C and why it displays those…

Paulo
- 325
- 3
- 16
0
votes
2 answers
strange behaviour of comparing two signed integers in a for loop
I am trying to solve a problem stated as follows: given a set segments, and a set of points, calculate how many segments contain each point.
The problem that I have encounterd is when I have to count how many times a point is contained by a segment.…

Endrit Sino
- 113
- 4