0

is it efficient to store for example 64 bit number as 2 32 bit integers, on a computer that can handle only 32 bit, etc 128 as 4 32 bits, or is there a better alternative like storing the digits instead, or using strings.

if it is efficient, what is the method to print out the large number, it seems too complicated to do so, so would it be better to store it as digits/string instead?

would have to define an +/-/*/% operation, but just reading a large number and storing into an array of integers, or printing out an a large number from an array of integers seem to complicated, so is the data structure too complex?

how would u printf a large number represented as 2 32 bits on 32 bit pc? my solutions seem too complex so it seems the datasture isn't effective? idk

userx1234
  • 43
  • 7
  • I've never used it, but if you need numbers bigger than what fit in the primitive types there are 3rd party libraries available to handle it, such as this one: https://gmplib.org/ – yano Mar 31 '19 at 16:56
  • yea i know of the lib, but is this method efficient or even possible – userx1234 Mar 31 '19 at 16:58
  • Storing one-bit-per-bit seems the most (space)effective. – wildplasser Mar 31 '19 at 16:58
  • Yes, it is efficient (but try different methods and **measure** time, memory, temperature, noise, ...); yes it is possible. – pmg Mar 31 '19 at 17:00
  • 1
    that's the most efficient way to store big numbers. There are already a lot of questions about that [How does a 32 bit processor support 64 bit integers?](https://stackoverflow.com/q/23038451/995714), [How are numbers greater than 2^32 handled by a 32 bit machine?](https://stackoverflow.com/q/3897906/995714), [__int64 on a 32-Bit machine?](https://stackoverflow.com/q/2692329/995714), [Signed 64 by 32 integer division](https://stackoverflow.com/q/1089265/995714), . Doing big int operations in string is the worst, both in memory consumption and CPU time needed – phuclv Mar 31 '19 at 17:03

0 Answers0