Giter Site home page Giter Site logo

decimal-to-binary's Introduction

To convert a decimal number to binary code, you can follow these steps:

  1. Divide the decimal number by 2.
  2. Write down the integer result (0 or 1).
  3. Write the remainder (0 or 1) on the right side.
  4. Divide the integer result again by 2.
  5. Write down the new integer result (0 or 1) to the left of the previous remainder.
  6. Write the new remainder (0 or 1) to the right of the previous remainder.
  7. Repeat steps 4-6 until the integer result is 0.

For example, to convert the decimal number 10 to binary:

  1. 10 divided by 2 is 5, with a remainder of 0.
  2. Write down 0 on the right side.
  3. 5 divided by 2 is 2, with a remainder of 1.
  4. Write down 1 to the left of 0.
  5. Write down 1 to the right of 0.
  6. 2 divided by 2 is 1, with a remainder of 0.
  7. Write down 0 to the left of 1, and 0 to the right of 1.
  8. 1 divided by 2 is 0, with a remainder of 1.
  9. Write down 1 to the left of 0, and 1 to the right of 0.
  10. The binary equivalent of 10 is 1010.

decimal-to-binary's People

Contributors

gacheruh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.