chen-dahe@CS.Yale.EDU (Dahe Chen) (01/26/89)
It may be a stupid question but I am perplexed by the code like the following: ... doubel A , B ; ... if( (int) A <= (int) B ) { statement1 ; } else { statement2 ; } ... I am having the case that the integral parts of A and B are equal and the control goes to statement2. My question is that am I casting A and B to integers properly. If not, what is the correct way. Please e-mail to me. Thanx in advance. ------- Dahe Chen internet: dchen@twolf.ce.yale.edu ( @venus.ycc.yale.edu ) chen-dahe@cs.yale.edu bitnet: dchen@yalevms
jd@csd4.milw.wisc.edu (James R Drinkwater) (01/31/89)
Will I run into any problems with the following:
struct something *ptr;
...
func((int)ptr);
...
func(arg)
int arg;
{
...
return(arg);
}
Thanks in advance-
Jim Drinkwater
boyne@hplvli.HP.COM (Art Boyne) (01/31/89)
jd@csd4.milw.wisc.edu (James R Drinkwater) asks: > Will I run into any problems with the following: > > struct something *ptr; > ... > func((int)ptr); > ... > func(arg) > int arg; > { > ... > return(arg); > } Certainly will, on machines where sizeof(pointer) > sizeof(int). The implementation of C for the 68000 I've been using for the last five years has sizeof(pointer)=sizeof(long)=32 bits and sizeof(int)=16 bits. Art Boyne boyne@hplvla.HP.COM