Skip to content
/ Switch Public

An algorithm to change the base of any decimal number (N10) to any specified base (B).

Notifications You must be signed in to change notification settings

Ba3a-G/Switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Switch

An algorithm to change the base of any decimal number (N10) to any specified base (B). It supports integers only for now and upto base 85.

N10 => XB

If there are non-numeric symbols involved, it also returns a dictionary to map the symbols. For example, the following symbols are used in Hexadecimal:

Hex A B C D E F
Decimal 10 11 12 13 14 15
from switch import Switch

example = Switch()

example.toBinary(97)
example.toHexadecimal(97)
example.switch(97, 14)

# Resposes
- 1100001 # Binary
- ['61', {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}] # Hexadecimal
- ['6D', {'A': 10, 'B': 11, 'C': 12, 'D': 13}] # Base 14

About

An algorithm to change the base of any decimal number (N10) to any specified base (B).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages