Go Down

Topic: Is it possible to do 32 * 32 bit multiplication on arduino due. (Read 679 times) previous topic - next topic


since the int or long data type in due can support till a maximum of 32 bits. So will it be possible to do a 32 * 32 bit multiplication. If possible then how can we get the output.


Yes, it is possible.  I just did it in the example below.  However, like you, I am learning how to use the Due.

Code: [Select]
  char outBuf[60], rrBytes[17];
  int k;
  unsigned long long rr;
  unsigned long xx = 0x0001FFFF;
  unsigned long yy = 0x00300000;
  rr = (unsigned long long)xx * yy;
  for( k=0; k<8; k++)
    sprintf( &rrBytes[k*2], "%02X", ((unsigned char *)&rr) [k]);
  rrBytes[16] = '\0';
  sprintf( outBuf, "\n  %08X * %08X = %llx  rrBytes[0..7]= %s", xx, yy, rr, rrBytes);

This will produce the output line below:
  0001FFFF * 00300000 = 5fffd00000  rrBytes[0..7]= 0000D0FF5F000000

Note the internal ordering of the result rr in rrBytes[0..7].  It is the Intel type ordering.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131