1

I would like to use larger numbers than an unsigned long long in Arduino. Is that possible?

  • 1
    You should look up the BigNumber library see if it is suitable for your needs. – Majenko Dec 4 '15 at 9:39
  • But... why do you need them? Usually when someone needs larger numbers then he has probably chosen the wrong algorithm... – frarugi87 Dec 4 '15 at 11:11
  • I'll check it out. – Andreas Hartmann Dec 4 '15 at 11:56
  • The entire point of my project is working with large numbers. – Andreas Hartmann Dec 4 '15 at 11:56
3

There are many ways to use numbers bigger than an unsigned long on Arduino. The right one depends on the application.

Floats and Doubles floats and doubles types on Arduino can hold exact integers up 2^53. That is a very large number. They are built into the Arduino compiler.

uint64_t The uint64_t type can hold exact integers up to 2^64. That is a very large number. This type is built into the Arduino compiler, but note that some Arduino library functions do not have versions for this type so may need to down-convert for printing and serializing and stuff like that.

BigNumber (or bc) The BigNumber type can represent exact numbers (integer or otherwise) limited only by available memory- but certainly hundreds of digits long on Arduino. These are extremely big numbers. This type is not built into the Arduino, but there is a nice Arduino library version available...

https://github.com/nickgammon/BigNumber

Again, this type is not supprted by the Arduino built-in library functions so you will need to either down-convert or find BigNumber compatible functions for things like printing and serializing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.