Closed mariavd closed 5 years ago
The documentation for the library here mentions:
Each digit requires a byte of memory, plus some overhead (eg. where the decimal point is) - large numbers will soon gobble up the available memory.
The later versions of the IDE must have slightly more overhead than when I tested on an earlier version. If you change the number of decimal places like this:
BigNumber::begin (45);
Then it works up to sin(90).
As a general rule with this library, if it locks up try reducing the precision. We are using a processor with only 2 k of RAM.
Indeed, thank you for your suggestion. Even reducing the precision to 49 decimal digits sorts out the problem. Also, I tested compiling with -O2 instead of -Os and the additional optimisation made it possible to run the code with 60-digit precision. It's not that I truly need that many digits for my own project but I just wanted to find out what is going on.
For the sake of book keeping (50 digits): -Os: Sketch uses 10248 bytes (31%) of program storage space. Maximum is 32256 bytes. Global variables use 380 bytes (18%) of dynamic memory, leaving 1668 bytes for local variables. Maximum is 2048 bytes.
-O2: Sketch uses 12036 bytes (37%) of program storage space. Maximum is 32256 bytes. Global variables use 380 bytes (18%) of dynamic memory, leaving 1668 bytes for local variables. Maximum is 2048 bytes.
I am now closing the issue.
Firstly, a great idea to port the big number library for microcontrollers!
I uploaded the examples program sine.pde on an Arduino Uno clone through Arduino IDE 1.8.5 but I get weird locks of the Serial output. The serial console consistently produces only:
I thought that I could print the time when each iteration begins, and oddly enough, the loop reached 30 degrees before locking again.
Printing the iteration index of the
sine
routine shows that it always would reach precision = 19 and then just dies:Do you have any suggestion what could be causing this behavior? I have access to an oscilloscope but I am not experienced with it. Can it be useful for debugging? Thanks.