Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[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.)
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top