how can i convert string os size[10] to float. also i cannot use atof or sscanf. im asked to use bitwise or anyother methos which will take less processiong time.
is there anyway. thank you
shriagni 0 Newbie Poster
Recommended Answers
Jump to Postyou could convert one character at a time. start out by multiplying the result by 10 add the character and subtract '0', similar to how you would convert an integer
char inputstr[] = "123.45"; float result = 0.0F; // convert 1st character result = (result * 10) …
Jump to PostIf you can't use build-in standard C functions, then you need to figure out what I posted.
Any decimal digit in a string can be converted to its binary equlivalent by simply subtracting the ascii value of '0'. For example, '1' - '0' = 1. If you look up …
Jump to PostYou need two loops, not 1.
For all digits before the decimal, you need to multiply the total by 10 then add the value. Byt the way use a while loop.When you get to the decimal you need to start a new loop to deal with the characters …
Jump to PostI. The keyword here is newbie, I think.
LOL! I've almost done that myself a couple of times.
All 15 Replies
ndeniche 402 Posting Virtuoso Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
shriagni 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
shriagni 0 Newbie Poster
Aia 1,977 Nearly a Posting Maven
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
ndeniche 402 Posting Virtuoso Featured Poster
shriagni 0 Newbie Poster
ndeniche 402 Posting Virtuoso Featured Poster
jefftanner -1 Newbie Poster
jephthah commented: you resurrected a year-old thread for this crap? a massive IF statement? terrible. -1
Prabakar 77 Posting Whiz
mitrmkar 1,056 Posting Virtuoso
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Prabakar 77 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.