Hello,
I'm working on a robotic project and I'm trying to implement inverse kinematics.
My issue is that, with an Arduino Uno R3, I can't seem to figure out how to work with big numbers.
An example would be 2147299: the correct result is 87906 but the arduino displays 22370 as the result. This result is given when using a long variable, which should go as far as 2^35.
I don't really know what the problem could be and I can't seem to find any solution online.
If anyone has any idea why this is happening, it would help me a lot!
Thanks
P.S. I'll be inserting the basic code I estrapulated from the more complex code of my project in order to examine better the problem
long a;
void setup() {
Serial.begin(9600);
a = 2*147*299;
Serial.println(a);
}
void loop() {
}
That's great, thank you so much. The code works but I can't seem to make it work if I use variables instead of the three values inside the multiplication.
Is this a syntax error?
uint32_t a;
int b = 147;
int c = 299;
int d = 2;
void setup() {
Serial.begin(9600);
a = b*c*d UL;
Serial.println(a);
}
void loop() {
}