![]() |
int times long?
What happens when I multiple an int by a long, is the result an long or an int?
|
Re: int times long?
Depends, what did you declare your answer variable to be?
int answer a * b = answer would result in an integer answer |
Re: int times long?
I can never remember this, and my K&R is back at school.
int A; long B; int answerint; long answerlong; I think having a long in the expression casts it to long: A * B produces a long. But to be sure you can cast it: answerlong= (long) (A * B); |
Re: int times long?
With a long as one of the operands, the Microchip C compiler will do a 32-bit multiplication. The result will be a long.
|
| All times are GMT -5. The time now is 23:44. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi