Go Down

Topic: Is it possible to do 32 * 32 bit multiplication on arduino due. (Read 790 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