[SOLVED] double to decimal value conversion problem

Status
Not open for further replies.

sachinkp21587

Member level 2
Joined
Mar 15, 2010
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
india (U.P.)
Visit site
Activity points
1,703
here i am using mplab c18 compiler to try to display '1234567890' value as it on lcd

unsigned char sachin[8];
unsigned double voltage = 0,step = 3215820;

voltage = 1234567890;
sachin[0] = (char)(voltage/1000000000) + 0x30;
sachin[1] = '.';
sachin[2] = (char)(voltage/100000000)%10 + 0x30;
sachin[3] = (char)(voltage/10000000)%10 + 0x30;
sachin[4] = (int)(voltage/1000000)%10 + 0x30;
sachin[5] = (int)(voltage/100000)%10 + 0x30;
sachin[6] = (int)(voltage/10000)%10 + 0x30;

sachin[7] = ' ';

i am getting 1.23457. dont know how type conversion worked for sachin[4]&[5] but i am unable to do the same for sachin[6]. kindly explain and suggest how to solve this issue.

Regards,
Sachin
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…