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

I'm trying to detect if there is unsigned overflow when adding the 2's complement representation of 2 signed integers (using a custom SignedInteger class that wraps modulo 2**bits if the value leaves ...
nonhuman's user avatar
  • 141
4 votes
2 answers
183 views

I'm seeing a strange (to me) difference in behavior between Clang and GCC when comparing an integer with its negation. Also, pre-v12 GCC behaves like Clang. Code is below, but also here's a live link ...
jwd's user avatar
  • 11.4k
6 votes
4 answers
356 views

For example, if I want to add two unsigned 8-bit integers together, I know I will need to store the result in a 16-bit integer. Otherwise, I run the risk of overflowing. This problem gets more ...
Joseph's user avatar
  • 61
1 vote
1 answer
61 views

I have this program that is supposed to select one color channel from an image, and square each element elementwise. However, it is not returning any results greater than the values in the first array?...
Gad11ng's user avatar
  • 43
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
0 answers
407 views

I am currently using an open source Python package called snompy (https://github.com/TomVincentUK/snompy). While implementing the package, a function that defines the transfer matrix returns an ...
Ilario Bisignano's user avatar
-3 votes
2 answers
118 views

I want to understand more about int overflow in C++ on a 64-bit system. So I would like to stick to int for my understanding without casting / extending the type to unsigned or 64-bit and I am on ...
khteh's user avatar
  • 4,280
0 votes
1 answer
131 views

I'm wondering if it is allowed in C++ to use overflow on purpose. In specific I want to increase a counter every cycle and when uint32_max is reached start from 0. In my mind the easy way would be: ...
gnicki's user avatar
  • 83
1 vote
2 answers
107 views

In running minimum/maximum problems, the e.g. minimum-so-far is often initialized to \infty in order to guarantee we "capture" every minimum, no matter where it is located. In Haskell, we ...
Brendan Langfield's user avatar
1 vote
1 answer
162 views

I am working on a project where I need to implement a Neural Network on a microcontroller in C, and execution time is critical. I am trying to try techniques to speed up the running of the code, and ...
Pranav's user avatar
  • 13
2 votes
1 answer
478 views

I have a variable on which I do a lot of arithmetic operations. My code was something like this: let a: u32 = 3; let res = (a*2) - 42 I had an overflow when a is too low, so I had to use ...
Olivier Lasne's user avatar
0 votes
0 answers
218 views

I'm working with really big tensors from pytorch, and as a result of a certain operation I need my tensor to maintain really big values(which represent some indexes), but obviously overflow makes all ...
SamuelMastrelli's user avatar
5 votes
1 answer
102 views

I am performing the following calculation: unsigned long long int interval = (ui->spinBox_2->value() * 60 * 60 * 1000) + (ui->spinBox_3->value() * 60 * 1000) + (ui->spinBox_4->value()...
Alan Shiah's user avatar
  • 1,086
-1 votes
1 answer
182 views

Rust panicked: attempt to multiply with overflow I'm trying to make a polynomial for the "AES" encryption algorithm. The fn new() is meant to construct the bit vector representation of a ...
Rust Coder's user avatar
2 votes
1 answer
106 views

So I was playing around with char* and unsigned char* pointers. And I came across this issue: Code: #include <stdio.h> void func(unsigned int max) { unsigned int* intptr = &max; ...
programk5er's user avatar
0 votes
1 answer
115 views

Apparently, gnu truncate on my x86_64 system does not support creating files with sizes of size >= 8EiB (= 2^63 Bytes = 9223372036854775808 Bytes). /usr/bin/truncate: ELF 64-bit LSB pie executable, ...
Semnodime's user avatar
  • 2,035
0 votes
1 answer
566 views

In the pic of the ALU, I've implemented the logic to calculate the zero, negative and carry flags. But I can't figure out how to implement the overflow flag without using the second last carry (carry-...
Venkat Balachandra's user avatar
1 vote
1 answer
63 views

I was attempting the #69 problem of leetcode, which involves finding square root of given number. I proceeded via a binary search approach. int mySqrt(int x) { if (x==0 || x==1){ return x; ...
Yogesh Yadav's user avatar
0 votes
0 answers
33 views

I found interesting problem, and can't find the proper answer: The error c2148 happens, when you try to create array with 2^31 + 1 elements. Same errors I found in another compilers: Clang, GCC, etc. (...
Andrew Buryakov's user avatar
0 votes
2 answers
157 views

I have been trying to understand the integer overflow in C-programming. I am confused about whether the final value output depends on the initial datatype given to the variable during declaration or ...
Abhijeet Gautam's user avatar
1 vote
1 answer
174 views

In R, I need to calculate Cliffs delta. Here is the formula: Where xi is an observation in group A, and xj is an observation in group B, and [xi > xj] is 1 if xi > xj is true. Here is Cliff's (...
EmilA's user avatar
  • 179
2 votes
2 answers
254 views

I am so new in C and so far I didn't comprehend how to prevent from integer overflow, I read many articles but still I am not 100% sure! in this case int ft_sqrt(int nb) { long int sqrt; ...
Negar Nasiri's user avatar
1 vote
2 answers
220 views

I have coded a program which calculates Fibonacci Series in C++. Here's the code below: #include <iostream> using namespace std; int main() { int n, t1 = 0, t2 = 1, nextTerm = 0; cout &...
Swapon Das's user avatar
2 votes
1 answer
168 views

In a Sparse dataframe, the sum() method applied on the whole dataframe gives wrong results, while sum() applied to specific column or to a dataframe subset works. It looks like an overflow issue for ...
Dudelstein's user avatar
1 vote
1 answer
125 views

The following example can be found in many places on the internet: The following code excerpt from OpenSSH 3.3 demonstrates a classic case of integer overflow: (bad code) Example Language: C nresp = ...
HangingParens's user avatar

1
2 3 4 5
23