can someone please give me some basic code sample using MOD op for decimal to binary up to BASE 10

ty
ex.
input 110
base 2
print 6

Recommended Answers

How many threads are you going to start asking essentially the same question?

Jump to Post

All 2 Replies

How many threads are you going to start asking essentially the same question?

How about how to do it step by step?

"110" in base 2, to convert to base 10, you start with the right most number.

The third position in a string = 0 * 2^0 = 0
The second position in a string = 1 * 2^1 = 2
The third position in a string = 1 * 2^2 = 4

The total = 0 + 2 + 4 = 6

Is that the way you compute the base 10 from a base 2? :) Now, you just need to convert that into an algorithm (step-by-step for programming).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.