2007年10月21日 星期日

BCB decimal is gone 相除後小數點不見了


I just did math in BCB and found decimal is gone, all 0, even I used double, float, etc........


then I figure out there is one rule in C program which is


interger divide by interger the result is interger. decimal divide by decimal result decimal.


Unless I used decimal, there will not have decimal exist.


the code is modified to force type transforming which means putting an "(double)" right after "=" on your demand.


ex:


int a = 65536, b = 12028;


double c;


c = (double) b/a;




沒有留言: