Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

big number operation problem #117

Open
qaz1423078740 opened this issue May 19, 2023 · 0 comments
Open

big number operation problem #117

qaz1423078740 opened this issue May 19, 2023 · 0 comments

Comments

@qaz1423078740
Copy link

qaz1423078740 commented May 19, 2023

I would like to ask how BIG data is represented, is it array addition?
For example, {254,1} means 255. Also, is there an upper limit for a single element of array?
I tried to add two big numbers 2147483645 to show what is the value of -6, I think there is no carry operation, I don't understand. Here is the test code I did

BIG a;
BIG b;
BIG d;
BIG_one(a);
BIG_one(b);
int c = 2147483644;

BIG_inc(a, c);
BIG_inc(b, c);
// BIG_toBytes(b,a);
BIG_add(d, a, b);
for (int i = 0; i < sizeof(d) / sizeof(d[0]); i++) {
Serial.println(d[i]);
Serial.println(" ");
}

-6 means ?
Is this modification correct?

BIG a;
BIG b;
BIG d;
BIG_one(a);
BIG_one(b);
int c = 2147483644;

BIG_inc(a, c);
BIG_norm(a);
BIG_inc(b, c);
BIG_norm(b);

BIG_add(d, a, b);

for (int i = 0; i < sizeof(d) / sizeof(d[0]); i++) {
Serial.print(d[i]);
Serial.println(" ");
}

536870906
14
0
0
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant