I have a problem that I am having trouble solving. I have a string of undefined length containing '0' or '1'. I need to convert this string to decimal... but I CANNOT store it in anything but another string. My issue is how to do this?! I have been thinking of maybe using base 1024, convert it to base 1000 + base 24 and store the 24 in an unsigned long long int... but even that might not work. Any ideas?
Labdabeta
182
Posting Pro in Training
Featured Poster
Recommended Answers
Jump to PostHello Labdabeta,
I hope you are asking to convert the string into integer(binary number) and then converting it to decimal. If yes,try this one..
For example, if there is '1' in a[0] then subtracting a[0] and '0' will give 1.int b; char a[100]; b=a[0]-'0';
The ASCII …
Jump to Post> First of all, assuming your binary string is stored from most significant bit to least significant bit, you will have to traverse it in reverse
No no no. Direct traversal is much simpler. Two methods need to be implemented: double a decimal string and add a bit value …
All 6 Replies
Arbus
25
Practically a Master Poster
Moschops
683
Practically a Master Poster
Featured Poster
Labdabeta
182
Posting Pro in Training
Featured Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
nezachem
616
Practically a Posting Shark
mike_2000_17
commented:
nice and simple, I like it!
+11
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.