Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
93 views

I'm migrating my project from .NET Framework 4.7.2 to .NET 9.0. Now I see that casting a negative double to uint is different. .NET Framework 4.7.2: double codeDouble = -2147287039.0; uint codeUint = (...
snowrunner's user avatar
4 votes
3 answers
187 views

My platform is x86_64, and assume there are 3 variables whose types are all uint16_t: uint16_t a, b, c; And for the following two code snippets: (1) uint16_t tmp = b - a; uint16_t result1 = c - tmp; ...
Nan Xiao's user avatar
  • 17.7k
0 votes
2 answers
151 views

I'm reading The C Programming Language by K & R 2nd edition and got to the bitwise operators. Why, on C, the Complement (~) Operator applied to a N number, returns -(N + 1) ? When it normally just ...
nerdpanda's user avatar
3 votes
1 answer
157 views

std::atomic::fetch_add() (or atomic_fetch_add() in C11) is based on two's complement for operations on signed integers. This is a different convention from the usual signed integer arithmetic, in ...
kakkoko's user avatar
  • 353
0 votes
4 answers
187 views

How could I implement signed and unsigned multiplication of two 64 bit numbers, widened into 128 bits, and discarding the low 64 bits, returning the high 64 bits? The multiplication must properly wrap ...
l-m's user avatar
  • 5
0 votes
1 answer
414 views

I'm reading a textbook on systems programming and it states that an overflow occurs for unsigned integers if and only if the carry-in bit is mismatched with the carry-out, in the left-most bit. So if ...
Addem's user avatar
  • 4,013
0 votes
1 answer
878 views

I am in the process of learning C/C++, so for some this might be a basic question but it is confusing to me. Beautiful answers are given here related to how we interpret positive and negative numbers ...
Cosmos's user avatar
  • 145
-1 votes
2 answers
124 views

i have a question about relational operators are they always give correct results ? because if we run this line of code it will result 1 instead of 0 cout<<(ULLONG_MAX==-1); and if we keep ...
Mohamad_T's user avatar
1 vote
3 answers
562 views

I have a value int x where I want to conditionally add (for example) a value int y to, contingent on bool c. I could write code like this: bool c; // C23, or stdbool.h macro for _Bool. Converts to ...
CPlus's user avatar
  • 5,110
1 vote
1 answer
175 views

3 9 6 F E 2 + 5 3 8 A A A This is the problem that I have to solve assuming two's complement addition. I know how to find the two's complement of each. C 6 9 0 1 E A C 7 5 5 6 However, most of the ...
AnonymousThankfulPerson's user avatar
0 votes
1 answer
455 views

I'm using the cpp_int header file from boost/multiprecision and for some reason when I cast -1 to a uint256_t then cast it back to an int256_t, it keeps the same value (~1.15e77). When I increment ...
amillerp's user avatar
1 vote
0 answers
51 views

I am adding two big numbers in GAS, I have used the online big number calculator to check the sum first, which is -396,154,063,093,444,159,558. I also am using SASM, an asm IDE, and the result from ...
ntos's user avatar
  • 379
3 votes
1 answer
291 views

I would like to input a text string ffff to a int16_t, the value should be -1. Here is a simple test C++ program: #include <iostream> #include <iomanip> #include <stdint.h> int main(...
ollydbg23's user avatar
  • 1,220
-4 votes
1 answer
523 views

I have some doubts about how two's complement is implemented in CPU. Does the CPU always work with two's complement?. If not, how it knows when to apply it for substraction. From my point of view, I ...
Sosa's user avatar
  • 23
-1 votes
1 answer
111 views

Here's what I have so far: decimalEquivalent is variable that represents an integer. #One's complement of the binary string is shown onesComplement = bin(~decimalEquivalent) print(f'The negative no (-{...
Beginner's user avatar
0 votes
1 answer
45 views

Given bytes as HEX: 710e00fe I do the following: int value = (*(int*)([bytes bytes])); int exp = value >> 24; int mantissa = value & 0x00FFFFFF; And I get mantissa = 3697 and exponent = -2....
Grew112's user avatar
0 votes
2 answers
139 views

There are tons of previous threads about how to apply 2's complement and how to interpret the number which I fully understand; however, what I'm confused about is the technical definition: that is, ...
gowerc's user avatar
  • 1,109
0 votes
0 answers
107 views

from fxpmath import Fxp c = Fxp(complex(3.2500+2.0625j), True, 8, 4) # (val, signed, n_word, n_frac) print(c) print((c).bin()) # binary representation d = Fxp(complex(2.0625+5.2500j), True, 8, 4) #...
mohammed zeeshan's user avatar
0 votes
0 answers
67 views

repnz scas al,BYTE PTR es:[edi MOV eax,ecx NOT eax value of eax changed from 0xfffffffc to 0x3 after these lines.
Thrain's user avatar
  • 1
1 vote
1 answer
1k views

I'm learning about x86 assembly(8086 to be more specific) and I'm confused about the concept of flags, I tried searching about it online and found this image : According to the image , after the ...
blake 's user avatar
  • 107
0 votes
1 answer
62 views

I have a document that shows a data in HEX, and split it into multi part (head, TransactionID, MessageType and ...) There is a problem in this document, and it is for example for TID they write ...
Mahdiyar's user avatar
0 votes
1 answer
102 views

If A = 01110011, B = 10010100, how would I add these? I did this: i.e: 01110011 + 10010100 = 100000111 Though, isn't it essentially 115 + (-108) = 7, whereas, I'm getting -249 Edit: I see that ...
spencer's user avatar
  • 138
-1 votes
1 answer
436 views

mov ax, 0ffffh inc ax inc ax Was watching a video on basic Intel X86 Assembly. I thought 0FFFFH was 65535 but in the video they got -1 instead (before the inc instructions run). Just wondering how ...
localhost's user avatar
0 votes
2 answers
2k views

I've seen a couple old posts that had a similar context but the answers were code snippets, not explanatory. And I can't even get the code offered in those answers to compile. I apologize in advance ...
grimsweepa's user avatar
2 votes
2 answers
535 views

I have coordinates stored in HEX, which from searching online appear to have used Signed 2's Complement to handle the negative values. I'm getting a bit lost with where the various conversions are ...
Toasty's user avatar
  • 61

1
2 3 4 5
14