Category "integer-overflow"

How can I calculate the tens place value of 2^100 in C++?

How can I calculate the tens place value of 2^100 in C++? I tried this; #include <cmath> #include <iostream> using namespace std; int main(){

How can I safely add and clamp a signed integer in C?

I have a value, of type signed int, which is always clamped between, for example, ±1073741824 (2^30). I should be able to safely add or subtract any arbi

How to check for overflow in duration_cast

I need to convert one kind of std::chrono::duration to another kind but I need to know when such a conversion is not possible because the value would not be rep

perl: Finding mean and variance of large numbers without overflow

I am using a subroutine (stats) to calculate statistics for a list of numbers. These numbers may be big enough to lose precision if stored as normal perl number

Modular inverses and unsigned integers

Modular inverses can be computed as follows (from Rosetta Code): #include <stdio.h> int mul_inv(int a, int b) { int b0 = b, t, q; int x0 = 0, x1

How do I check for overflow after an Interlocked.Increment in C#?

What is the correct way to check for an overflow after a call to Interlocked.Increment? I have an ID generator that generates unique ids during the program's ex

Reading the SECURITY_ENABLED flag of Group in Active Directory

I'm trying to read the SECURITY_ENABLED flag of a groups groupType property. The problem is that the value I retreive by using DirectoryEntry entry... entry.P