3 ms·
This is why it's a good idea to have a real integer type.
by eutectic 5y ago
This is why it's a good idea to have a real integer type.
- enriquto 5y agoIsn't it impossible? Integers go arbitrarily large but computers don't.
- asdf3243245q 5y agoComputers also go arbitrarily large. Not infinite, but arbitrarily large. A real number type could be bounded by the amount of RAM you have.
- alisonkisk 5y agoYou can use disk storage too. And network storage.
- btilly 5y agoIt is possible within the limits of available memory on the computer. Rather than the usual limit of a fixed number of bits. I've ironically found that big integer libraries sometimes optimize math routines more than string conversion. This was quite annoying for me when I optimized the factorial function in Ruby, and found that generating the string was my bottleneck. I then optimized that as well. :-)
- Sohcahtoa82 5y agoThey can go large enough for anything that matters. A quick Google says there's an estimate of 10^78 to 10^82 atoms in the universe. That number would be able to be stored in well under 300 bits.
- ithinkso 5y agoUniverse is tiny compared to mathematics and software, even simply RSA keys are already 2048bit. Lots of problems suffer from 'combinatorial explosion' [1]. I recently learned about the Archimedes's cattle problem, the solution is of order 10^206544 [2] [1] https://en.wikipedia.org/wiki/Combinatorial_explosion https://en.wikipedia.org/wiki/Combinatorial_explosion [2] https://en.wikipedia.org/wiki/Archimedes%27s_cattle_problem https://en.wikipedia.org/wiki/Archimedes%27s_cattle_problem
- Sohcahtoa82 5y ago10^206544 would still be less than 8 kB. You could store it on an Atari cartridge!