Top "Integer-arithmetic" questions

Anything related to integer arithmetic, i.e. arithmetic operations on integer numbers.

How can I add numbers in a Bash script?

I have this Bash script and I had a problem in line 16. How can I take the previous result of …

bash integer-arithmetic mathematical-expressions
Is unsigned integer subtraction defined behavior?

I have come across code from someone who appears to believe there is a problem subtracting an unsigned integer from …

c standards unsigned integer-arithmetic
How do you store an arbitrarily large integer value in memory?

I have to store an integer value that is larger than the maximum value for the long datatype. How would …

c memory-management integer integer-arithmetic
Perfect square and perfect cube

Is there any predefined function in c++ to check whether the number is square of any number and same for …

c++ algorithm math integer integer-arithmetic
How can I detect integer overflow on 32 bits int?

I know such topic was asked several times, but my question is about overflow on full 32 bits of int. For …

java integer bit-manipulation integer-overflow integer-arithmetic
Unexpected results when working with very big integers on interpreted languages

I am trying to get the sum of 1 + 2 + ... + 1000000000, but I'm getting funny results in PHP and Node.js. PHP $sum = 0; …

php node.js precision integer-overflow integer-arithmetic
Subtraction without minus sign in C

How can I subtract two integers in C without the - operator?

c math integer integer-arithmetic
Panicked at 'attempt to subtract with overflow' when cycling backwards though a list

I am writing a cycle method for a list that moves an index either forwards or backwards. The following code …

rust integer-overflow integer-arithmetic
Why is ushort + ushort equal to int?

Previously today I was trying to add two ushorts and I noticed that I had to cast the result back …

c# types integer-arithmetic