Skip to content

15dbooher/ftb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Fraction To Binary Converter (ftb)

by Daniel Booher

This is a python script that converts a fraction or non-fraction Decimal Number (base 10) to the equivalent Binary Number (base 2).

Currently it cannot convert from binary to decimal.

If you'd like to add this feature, please feel free to do so

Usage

python ftb.py <fraction> <number of decimals>

fraction is the base-10 number that you would like to conver to binary (Note: if it's a fraction it must be in decimal form!)

number of decimals is the number of decimals (degree of accuracy) placed after the whole number part of the output binary number (Use 0 for whole numbers!)

Fraction Example

Input: python ftb.py 123.456 3

Output: 1111011.011

Whole Number Example

Input: python ftb.py 123456 0

Output: 11110001001000000