Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting 100 1/8 to 100.125

Status
Not open for further replies.

gvielliard

Programmer
Nov 6, 2001
21
FR
Hi,
I am wondering if there is any existing function converting number of this format 100 1/8 to this format 100.125.
Thank you,
Gilles
 
Nope, you've gotta do it the hard way.

If it's a string, you'll have to parse out the pieces of the number (whole number, numerator, denominator), convert each one using atoi() and then divide the numerator and denominator to get the decimal value. Then you can use the sprintf() function to put the whole number and the decimal value back together.

Crazy, hey? X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top