Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
185 views

I have a C program that I made that is supposed to convert binary into a signed integer, but it does not give the correct result. Here is the function of the code that converts binary numbers to ...
Sebastian Llaurador's user avatar
0 votes
1 answer
127 views

In C, I encounter this weird problem: For the following code: #include <stdio.h> #include <math.h> int main(int argc, char *argv[]) { unsigned int i = 0; for (int j = i - 1; j < ...
William Li's user avatar
-3 votes
2 answers
106 views

why there is no output for this? #include <stdio.h> int main() { int i; int array[4] = {10, 25, 36, 42}; // int size=sizeof(array) / sizeof(int); for (i = -1; i < sizeof(...
aleena george's user avatar
0 votes
0 answers
77 views

how can I subtract 2 sign and magnitude binary numbers in assembly (ex : 11110110 and 10101011) I used SAL then I don't know how to pick out the sign bit, when we shift to left, our signed bit is ...
Maryam Shomali's user avatar
3 votes
3 answers
240 views

I tried to compare with strlen(string) with -1 but different methods gave different results: char string[] = {"1234"}; int len = strlen(string); int bool; bool = -1 < strlen(string); ...
chaganhu's user avatar
1 vote
0 answers
51 views

using (MemoryStream mem = new MemoryStream (bytes.Skip(4).toArray())) { using (BinaryReader reader = new BinaryReader(mem)) { UInt32 time1; UInt32 time2; Int64 time = 0; try{ time1 =...
duk3th3c0d3r's user avatar
0 votes
1 answer
156 views

Compare the following code. It's clear from the context that one pointer will always be bigger than the other and the result of std::distance() therefore positive. How do I idiomatically convert from ...
glades's user avatar
  • 5,392
0 votes
1 answer
491 views

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 ...
newbie1kenobi's user avatar
2 votes
1 answer
173 views

The following code is giving an error by saying the message "singed integer overflow". And the error is in this test case : input : 208170109961052 Output : 4611790103482368430 Expected ...
Nazmus Sakib Sibly's user avatar
2 votes
2 answers
451 views

I want to check if the reverse of an signed int value x lies inside INT_MAX and INT_MIN. For this, I have reversed x twice and checked if it is equal to the original x, if so then it lies inside ...
UNREAL's user avatar
  • 514
1 vote
2 answers
280 views

There are the following programs: #include <stdio.h> int main(void) { int i=2147483647; unsigned int j=4294967295; printf("%d %d %d\n",i,i+1,i+2); printf("%u %u %u\n&...
fuyingwei's user avatar
0 votes
2 answers
480 views

... the integer promotions are performed on both operands. Then the following rules are applied to the promoted operands: If both operands have the same type, then no further conversion is needed. ...
Robert Ilin's user avatar
4 votes
3 answers
543 views

I bumped into this while writing a program trying to print the constituent byte values of UTF-8 characters. This is the program that I wrote to test the various ~0 operations: #include <stdio.h> ...
Marcus Harrison's user avatar
0 votes
2 answers
6k views

I have a list of unsigned 32-bit unsigned integers that actually are supposed to represent 32-bit signed integers. For example 62714 = binary 1111010011111010 = signed -2822 when interpreted as two's ...
Yangorang's user avatar
-3 votes
1 answer
652 views

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 ...
Nishant's user avatar
  • 11
1 vote
2 answers
143 views

I am trying to access a json element with the name "long", but VS gives an error, it detects it as a 16 bit signed integer. The other elements in Json I can access , except element "...
Moonshine Diana's user avatar
2 votes
2 answers
119 views

There is a simple example: unsigned a = -5; int b = 5; if (a + b <= -1){ ... } To which type will cast a+b? To signed or unsigned? And is it noted in C-standard or compiler will decide what to do?
Anton Golovenko's user avatar
0 votes
2 answers
941 views

I'm porting some c code which is doing a modulo on an uint32_t. An uint32_t fits in a Java int bit-wise, but I cannot figure out how to perform a modulo operation on it without converting to a long. ...
Alexander Torstling's user avatar
0 votes
0 answers
109 views

Do we can view, how class int in python handles negative numbers by using two's complement? I want to see source code for that not theories, I already understand how that happens in cs but I don't ...
user avatar
0 votes
1 answer
565 views

I'm learning x86 assembly language and have no idea how to print negative integer using Irvine32 library. INCLUDE Irvine32.inc .data arry SWORD 10, -20, 30 .code main PROC mov eax, ...
Jasper's user avatar
  • 11
0 votes
1 answer
100 views

@R2 M=0 @R0 D=M @END D, JEQ @store M=D (LOOP) @R1 D=D-M @REMAINDER D, JLT @EVENLY D, JEQ @LOOP 0, JMP (REMAINDER) @R1 D=D+M @R2 ...
comp sci's user avatar
2 votes
2 answers
500 views

Suppose I want to define an integer literal which also allows for negative values, e.g. -12_km. I.e., I would like to do using coord_t = long long; coord_t operator "" _km(long long int); ...
Tim Kuipers's user avatar
  • 1,794
1 vote
1 answer
988 views

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 <stdio.h> int ...
fatalcoder524's user avatar
0 votes
0 answers
828 views

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 ...
P Oltergeist's user avatar
0 votes
2 answers
515 views

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 ...
Taseen A's user avatar
3 votes
2 answers
2k views

I am supposed to take signed integers from a user, calculate the sum of inputted numbers and then display the average. The problem is, negative numbers don't seem to be displaying correctly, although ...
halpme's user avatar
  • 27
0 votes
0 answers
350 views

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 ...
halpme's user avatar
  • 27
0 votes
0 answers
48 views

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 ...
raff5184's user avatar
  • 382
0 votes
0 answers
539 views

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. ...
gregwinn's user avatar
  • 971
-1 votes
1 answer
145 views

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, ...
Ahmed Faraz Siddiqui's user avatar
9 votes
1 answer
13k views

In intel instruction, idiv(integer divsion) means signed division. I got the result of idiv, but I don't quite understand the result. - Example 0xffff0000 idiv 0xffff1100 - My wrong prediction As ...
Jiwon's user avatar
  • 1,238
97 votes
6 answers
9k views

I saw the below code in this Quora post: #include <stdio.h> struct mystruct { int enabled:1; }; int main() { struct mystruct s; s.enabled = 1; if(s.enabled == 1) printf("Is enabled\n"...
iammilind's user avatar
  • 70.5k
0 votes
1 answer
585 views

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 ...
user avatar
9 votes
2 answers
6k views

Many lossless algorithms in signal processing require an evaluation of the expression of the form ⌊ a / 2b ⌋, where a, b are signed (a possibly negative, b non-negative) integers ...
DaBler's user avatar
  • 2,859
0 votes
1 answer
1k views

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 ...
The_Senate's user avatar
2 votes
3 answers
4k views

Question in short Is there a way to read two bytes as a signed integer? Details & example Given two bytes in java, each represents an integer, we can convert them to the int value they ...
Othman H's user avatar
4 votes
2 answers
2k views

I have a sensor which gives its output in three bytes. I read it like this: unsigned char byte0,byte1,byte2; byte0=readRegister(0x25); byte1=readRegister(0x26); byte2=readRegister(0x27); Now I want ...
muliku's user avatar
  • 486
1 vote
4 answers
5k views

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) ...
PHPLover's user avatar
  • 13k
2 votes
2 answers
513 views

thx for help my question is about ax value received from code below? mov al,22h mov cl,0fdh imul cl Actual machine result: ff9a What I expected: 00:9a (by multiplying in binary) The first number is ...
Hai Vaknin's user avatar
2 votes
2 answers
1k views

Motivated from a code snippet on this blog under "What happens when I mix signed and unsigned integers?" I decided to run it with few different values of signed and unsigned integers and observe the ...
user3276435's user avatar
0 votes
1 answer
368 views

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 ...
Harinder Pal's user avatar
0 votes
3 answers
2k views

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 -...
StarScr3am77's user avatar
5 votes
1 answer
8k views

I was tasked to write a program that displays the linear address of my program's PSP. I wrote the following: ORG 256 mov dx,Msg mov ah,09h ;DOS....
Sep Roland's user avatar
  • 41.2k
0 votes
1 answer
959 views

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 ...
Kirti Nikam's user avatar
  • 2,226
2 votes
3 answers
4k views

I want to hash strings of variable length (6-60 characters long) to 32-bit signed integers in order to save disk space in PostgreSQL. I don't want to encrypt any data, and the hashing function needs ...
tryptofame's user avatar
0 votes
4 answers
408 views

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 ...
John Hascall's user avatar
  • 9,444
-2 votes
2 answers
579 views

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^...
Ashish Ranjan's user avatar
1 vote
0 answers
985 views

I developed a Cordova application and it went through a security review, one of the findings was related to a plugin I use to make curl requests. The finding is graded as Heigh vulnerability. The ...
Moamen Mostafa's user avatar
1 vote
2 answers
1k views

I can only use ! ~ & ^ | + << >> I am writing this in C. I am trying to divide a number x by 2^n. So i thought if I shift x >> n that would work, but it does not work with odd negative ...
pootyy's user avatar
  • 55
3 votes
1 answer
260 views

Currently I am working on c and facing a confusion regarding signed int in structure and here I have given the example: #include <stdio.h> #include <string.h> struct { signed int age : ...
Dhaval Mistry's user avatar