4 ms·
Defaulting to bignums would turn every + in the program from O(1) to O(N). That makes secure programming pretty difficult - this attack's already bad enough: h
by astrange 10y ago
Defaulting to bignums would turn every + in the program from O(1) to O(N). That makes secure programming pretty difficult - this attack's already bad enough:
http://arstechnica.com/business/2011/12/huge-portions-of-web-vulnerable-to-hashing-denial-of-service-attack/ http://arstechnica.com/business/2011/12/huge-portions-of-web...
- qwertyuiop924 10y agoIt'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.