created: 07/15/2015; improved 04/10/16; improved again 04/22/23

# Decimal Integer to Binary Integer

The algorithm is:

```number = positive integer ;
bitstring = ""

while (number > 0 )
{
bit = number mod 2 ;
append bit to the left of bitstring;
quotient = number div 2 ;
number = quotient ;
}

mod means remainder after integer division.
div means quotient  after integer division.
```

To start: Enter a decimal representation of a not too big positive integer in the Positive Integer box.

Then: Click Initialize to assign the integer to number.

Then: Click Divide by Two to compute the quotient and remainder. The remainder will be 0 or 1. That bit is copied to the left of the bit string.

Click Repeat to go through the cycle again. Quit when the number has been reduced to zero.

# Decimal Fraction to Binary Fraction

The algorithm is:

```number = decimal fraction ;
bitstring = "."

while ( number > 0 )
{
number   = number * 2 ;
bit      = 1 or 0 left of the decimal point ;
append bit to the right of bitstring ;
number   =  digits right of the decimal point ;
}
```

To start: Enter a decimal representation of a fraction in the Positive Decimal Fraction box.

Then: Click Initialize to assign the fraction to number.

Then: Click Multiply by Two . A bit will appear in the 1's place. That bit will be 0 or 1. Copy it to the right of the bit string.

Click Repeat to go through the cycle again. Quit when the fraction is zero or you have enough bits.