hi ,
i am not much familiar with c programming.
i had written a code given below
Code:
val1 = (double)Vanlg/Vref;
val1 = (val1*2000)-2000;
val = (unsigned int)val1;
d4 = val/1000 ;
r1 = val%1000;
d3 = r1/100 ;
byt = r1 % 100 ;
d2= byt/10 ;
d1 = byt%10 ;
val1, val2 are double and val is unsigned int. d4, d3, d2 and d1 are display digit where value has been dislayed. according to calculation display should be zero or 1. but some time i get 534 value.
Code:
val1 = (double)Vanlg/Vref;
val1 = (val1*2000);
from the above two line i get value 1997, 1999, 2000.if i subtract 2000 from the above answer. then value are -3, -1, 0. but i am getting 534 and 0 . 0 is correct but what about 534.
please go through it tell me whats going on above.
thanking you..