Thread: int times long?
View Single Post
  #3   Spotlight this post!  
Unread 27-01-2008, 20:08
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
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);