Problems with GT60 long int multiplication and division

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problems with GT60 long int multiplication and division

1,453件の閲覧回数
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.
ラベル(1)
0 件の賞賛
返信
1 返信

647件の閲覧回数
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 件の賞賛
返信