Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. long binary_to_dec(long nb)
  2. {
  3. long final = 0;
  4. long temp = 0;
  5.  
  6. while (nb != 0) {
  7. if (nb % 10 == 1)
  8. final += temp;
  9. temp *= 2;
  10. nb /= 10
  11. if (temp == 0)
  12. temp = 1;
  13. }
  14. return (final);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement