1

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

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

1 Answer 1

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.

answered Dec 4, 2015 at 15:17
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.