Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long binary_to_dec(long nb)
- {
- long final = 0;
- long temp = 0;
- while (nb != 0) {
- if (nb % 10 == 1)
- final += temp;
- temp *= 2;
- nb /= 10
- if (temp == 0)
- temp = 1;
- }
- return (final);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement