Problems with GT60 long int multiplication and division

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with GT60 long int multiplication and division

1,024 Views
guilherme
Contributor I
Hi!
 
I have a problem when í'm doing multiplications and divisions with a long int format. When I do these operacions using int format, they work, but when I use a long int format, they didn´t work. I would like to know if someone can help me; I need to use this format because I need some precision and I don´t want to use a float format.
 
Thanks.
Labels (1)
0 Kudos
1 Reply

218 Views
CompilerGuru
NXP Employee
NXP Employee
Can you provide a sample of what you tried?
One special thing to watch out in C is that the operation size is only defined by the arguments, not by the way the result is used.
So in this sample:
int a,b;
long c0= a*b;
long c1= (long)a*(long)b;

c0 will be the result of a int multiplication while c1 is the result of a long multiplication. Apart from that I don't see why using longs should not work.

Daniel
0 Kudos