Is it possible to multiply two 16 bit numbers with Arduino 2560

I am a complete newbie in this field. I need to do some operations involving 16 bit X 16 bit multiplication. Is it possible to do that without using assembly. If possible then how will I be able to get the output ?

I tried as below :

int a = 0XABCD;
int b = 0X6789;
long c ;
c = a*b;
Serial.print(c, HEX);

But i am getting only 16 bits in the output.

Please can anybody help me out.

c = (long)a*(long)b;

You have to understand how contagion works in C (contagion is the way a compiler determines the type of an expression
based on the types of the subexpressions and the operator in question.

The default for integer operations is (signed) int. This means if all the subexpressions are int or smaller you
cannot get a long result, since the default result type is signed 16 bit. There will only be a cast widening the
result when the assignment is performed (too late).

So long as you cast one of the subexpressions to a long type the operator selected will be a long one.

So you can do:

  c = (long)a * b ;

or

  c = a * (long)b ;

but not:

  c = (long) (a * b) ;

to get what you want.

Note that if you are using char-sized variables and wanting char-sized intermediate results you have to
cast the result otherwise a 16 bit operation will be used (even if the result variable is a char) - however
I believe the avr-gcc compiler has special optimizations to help here, since it is very wasteful to use
16 bit intermediate results on an 8-bit architecture.

On larger processors the int type is usually 32bits and this is the size of a register - in other words the
default size is the natural size for the machine (not the case for the Arduino).