I'm a little bit confused..
Im porting a program written in MikroBasic to MikroCPro and I have some big problems with arithmetical operation.
Old program:
Code: Select all
hpianteettaro as longint
numFile as byte
distanza as word
larghezza as word
...
hpianteEttaro=numFile*100*100000
hpianteEttaro=hpianteEttaro/(distanza*larghezza)
...
and I haven't any problem with typecasting and after the operation the value of hpianteettaro was ok! :
(numFile*100*100000)/(distanza*larghezza)
example:
(numFile=4,distanza=300,larghezza=160 -> hPianteEttaro=833)
Porting in MikroC:
Code: Select all
unsigned long hpianteettaro;
unsigned short numFile;
unsigned int distanza as word;
unsigned int larghezza as word;
...
hpianteEttaro=(numFile*100*100000);
hpianteEttaro=hpianteEttaro/distanza;
hpianteEttaro=hpianteEttaro/larghezza;
...
the result is the same if I declare every operator like unsigned long!
What I've wrong?
What kind of rules I've to aplly?
Thanks a lot!
Franek