0

If all types of values (ints, floats, etc.) have limitations, how do programs like excel or games calculate numbers higher than these? Do the companies create their own proprietary calculators? Are there standard libraries that handle this?

edit: clarity

EindacorDS
  • 107
  • 1
  • 3
  • 11
  • 2
    http://stackoverflow.com/questions/15400031/c-what-variable-type-for-extremely-big-integer-numbers?lq=1 – Pavel May 09 '14 at 14:51
  • How do you know Excel calculate numbers higher than these? There are various integer types, represented on 8, 16, 32, 64, 128 bits. Does Excel use integers larger than 128 bits? There are various `big integer` type implementations in all important programming languages. Its similar with real numbers. – Marius Bancila May 09 '14 at 14:52
  • also: http://stackoverflow.com/questions/269268/how-to-implement-big-int-in-c – Nate Kohl May 09 '14 at 14:55
  • I don't know know what kinds of ints excel uses, I was speaking more hypothetically. If I'm writing 32-bit software that needs to make calculations on numbers higher than the `UINT_MAX`, how is this typically done? – EindacorDS May 09 '14 at 14:58
  • Thank you for the links, those responses should help. – EindacorDS May 09 '14 at 15:01

2 Answers2

4

By using "arbitrary precision" math libraries like Gnu MP Bignum Library. These libraries get around physical limitations of the hardware by using algorithms to combine multiple ints, floats, chars etc to represent and operate on a single number.

PaulProgrammer
  • 16,175
  • 4
  • 39
  • 56
0

Well, even you could write something simple. Like representing a number as an array of digits and implement all the needed mathematical operations for them. It is slower, of course, than a native machine types, but is does overcome the physical limitations.

And of course there is quite a number of libraries already written. Some are free like GMP, for sure there are some proprietary too. Actually GMP is a dependency of gcc, so I guess you can say its quite popular.

Is is standard? It depends what you mean by standard. It is not defined within the c++ standard. But some are popular (as gnu tools).

luk32
  • 15,812
  • 38
  • 62
  • I actually did just that. One of my first little projects was a calculator that could handle massive numbers. Now I'm trying to make some more practical applications, but instead of using my own system I'd prefer to use one that's more tried and tested. Something more efficient than a program written by a guy who's only been programming for about a year and a half. – EindacorDS May 09 '14 at 15:11