Using the BigNumber library program compiles but hangs on upload

If I uncomment the line below: //BigNumber N4 = PFD * N3;
in the code snippet. The program will compile but looking at the serial monitor on upload the output is nothing. When it is commented out, the four numbers are displayed. Any, help is appreciated. Thanks Mark

BigNumber Integer = 110;
BigNumber FRAC1 = "11359573";
BigNumber FRAC2 = "512";
BigNumber MOD2 = "1536";
BigNumber MOD1 = "16777216";
BigNumber PFD = "61440000";

BigNumber N11 = FRAC2 / MOD2;
BigNumber N1 = FRAC1 + N11;
BigNumber N2 = N1/MOD1;
BigNumber N3 = Integer + N2;
//BigNumber N4 = PFD * N3;

Serial.println (N11);
Serial.println (N1);
Serial.println (N2);
Serial.println (N3);
//Serial.println (N4);

http://snippets-r-us.com/

Please post code that reproduces the problem, not a snippet.

That part seems to run now. I must have had some issue with the serial monitor. However, in the following code. If I add 1 more element to the array sbuf (add "REFin")and change sbuf to sbuf[66]. The serial monitor only shows yes. It seemed to work earlier and i had the same problem when adding "Disable" and changing sbuf to sbuf[67].

A good run would display the following:

yes
0.333333333333333
11359573.333333333333333
0.677083333333333
110.677083333333333
6799999999.999999979520000

Hard to debug if it compiles but hangs when being displayed. Thanks for any help.

//#include <SoftwareSerial.h>
//#include <print.h>
//#include <print.cpp>
//#include <ProfileTimer.h>
#include <BigNumber.h>
//#include <BigNumber.cpp>

//BigNumber::begin(); //initialize library

void setup() {
Serial.begin (9600);
Serial.println ();
Serial.println ();
BigNumber::begin (20); // initialize library
BigNumber::setScale (15);

int R0[32] = {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,0,0,0}; // default 0x02006E0
int R1[32] = {0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1}; // default 0x0AD5551
int R2[32] = {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0}; // default 0x08006002
int R3[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; // default 0x00000003
int R4[32] = {0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,0,1,0,0}; // default 0x32008B84
int R5[32] = {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1}; // default 0x000800025
int R6[32] = {0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,1,1,0,1,1,0}; // default 0x035012076
int R7[32] = {0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1}; // default 0x012000007
int R8[32] = {0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0}; // default 0x0102D0428
int R9[32] = {0,0,0,1,1,0,1,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,0,0,1,0,0,1}; // default 0x01A19FCC9
int R10[32] = {0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,1,1,1,0,1,0}; // default 0x000C026BA
int R11[32] = {0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,1,1}; // default 0x00061300B
int R12[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0}; // default 0x00000041C

String sbuf[66] = {"68","00.0","000","00","122","880","000","1","N","Y","Enable","Disable",
"110","11","359","573","512","1536","16","777","216","61","44","110","677","0833","3333","3333","6800","000","000","1","Enable","4/5","2006E0",
"AD5551", "8006002", "Disable", "Disable", "Disable", "0", "3", "Digital Lock Detect", "Disable", "0.900", "Differential", "3.0v", "Positive", "Disable", "Disable", "Disable", "32008B84",
"800025", "Fundamental", "Enable", "9", "Disable", "Enable", "Enable", "+5dBm", "Enable", "Disable",
"35012076"};// "REFin", "Disable" ,"5.0ns","Frac-N", "12000007", "102D0428", "Enable", "26", "103"
// "30", "12", "2840", "592", "1A19FCC9", "Enable", "154", "99", "417", "Enable", "Enable", "C026BA", "613008", "0", "0", "41C", "60", "00.0", "000", "00", "60", "10.0", "000", "00", "1", "100", "40", "00.0", "000", "00", "41", "00.0", "000", "00", "100", "1"};

// test multiplication
BigNumber Integer = 110;
BigNumber FRAC1 = "11359573";
BigNumber FRAC2 = "512";
BigNumber MOD2 = "1536";
BigNumber MOD1 = "16777216";
BigNumber PFD = "61440000";

// test multiplication

Serial.println ("yes");
BigNumber N11 = FRAC2 / MOD2;
BigNumber N1 = FRAC1 + N11;
BigNumber N2 = N1/MOD1;
BigNumber N3 = Integer + N2;
BigNumber N4 = PFD * N3;

Serial.println (N11);
Serial.println (N1);
Serial.println (N2);
Serial.println (N3);
Serial.println (N4);

}

void loop () { }

Please use code tags.

Read this before posting a programming question

How to use this forum

  int R0[32] =  {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,0,0,0};  // default 0x02006E0

You are using int to hold 0 or 1? Isn't that wasteful? That is 832 bytes gone straight away, out of 2048 if you are using a Uno.

  String sbuf[66] = {"68","00.0","000","00","122","880","000","1","N","Y","Enable","Disable",

String is also not very memory efficient. It uses dynamic memory allocation, and using it to hold things like Y and N seems a bit wasteful too.

Hard to debug if it compiles but hangs when being displayed. Thanks for any help.

Classic symptoms of running out of memory. I don't even see where you are using R0, R1 etc. Why even declare them? Plus instead of naming them R0 to R12 why not use an array?

The BigNumber library itself uses RAM quite a bit (one byte per digit) and if you are doing big multiplications then the number of digits can get large quite quickly.

The arrays were going to be used later in the program, But, yes when I commented them out the proram ran so it was a memory issue. Now i know, my mistake. I am not a programmer by trade. So, I don't always no the best ways to do things. Can I ask how should i define the multiple R1, R2, R3 int arrays and the sbuf string array.
Thanks for any help Mark

Ok, I can define the R registers as char. But I don't know what to use for the sbuf array it looks like a bunch of strings to me .

Thanks
Mark

gorbema:
Ok, I can define the R registers as char. But I don't know what to use for the sbuf array it looks like a bunch of strings to me .

Yes, but why? Some of them look like numbers. Redesign? Say you had a rowing boat and you had to cross a river, and the boat only held a small amount. And say someone came along with a lot of half-empty boxes. Would you unpack them and repack them more efficiently?

I don't know what you are trying to do, but at the back of your mind needs to be the need to keep memory usage to a minimum.

When I was young processors only had a few thousand bytes of RAM (like the Arduinos), if that. You took that into account. Nowadays modern PCs have gigabytes of RAM, and you can more-or-less pretend that RAM is unlimited. You have to unlearn that attitude on microprocessors.

I suspect that, for what the OP is doing, he will need to keep it at the front of his mind.

@gorbema:
What exactly are you trying to build, anyway?

odometer:
I suspect that, for what the OP is doing, he will need to keep it at the front of his mind.

@gorbema:
What exactly are you trying to build, anyway?

Well, a PFD is a personal flotation device, or "lifejacket".