3 ms·
It's that, or have every + risk integer overflow. It's a small thing, but it's nice to do. Or at least detect overflows and move to bignum in the default numer
by qwertyuiop924 10y ago
It's that, or have every + risk integer overflow.
It's a small thing, but it's nice to do. Or at least detect overflows and move to bignum in the default numerical implementation. It's not end-of-the-world if you don't, but it helps avoid a lot of bugs...
- astrange 10y agoI really recommend having the program trap on overflow. There are some proposals like as-if-infinitely-ranged, which is like bignums but without having to actually store a bignum. It's really problematic to use them, though. Every integer would turn into a pointer, and the O(N) thing really is a problem. If you're doing secure coding you need careful control of data dependencies, since they create side-channel leaks, and nobody who makes "safe" languages appreciates this. Plus most people don't need numbers that big. I think it was even a mistake to make size_t 64-bit.
- qwertyuiop924 10y agoC actually makes it really hard to trap on overflow. It's one of the biggest reasons C kinda sucks. The way a lot of HLLs do it is to detect a potential overflow, and convert to bignum if needed.