Skip to content

Binary to decimal converters in numerous languages. Designed as a learning tool to compare common concepts across programming languages.

License

Notifications You must be signed in to change notification settings

mecaneer23/BinarytoDecimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BinarytoDecimal

Binary to decimal converters in many languages

File endings error

Resolve by opening the file in question in vim and running the following command

:set ff=unix

Current languages (53)

Language
Ada CoffeeScript F# Haskell Nim Python Scala Vala
Bash Common Lisp Fantom Java Objective-C R Scheme Vimscript
Batch Crystal Forth Java Blocks OCaml Racket Scratch Visual Basic
C D Fortran JavaScript Pascal Reason Swift Zig
C# Dart Gadot (GDScript) Julia Perl Rescript Tcl
C++ DogeScript Go Kotlin PHP Ruby TypeScript
Clojure Elixir Groovy Lua Powershell Rust V

Libraries and tools using BinarytoDecimal in existing languages

Library or tool Parent language
Bitsbox JavaScript
CSS HTML
HTML JavaScript
Haskell Style Python
Tkinter Python
Jupyter Notebook Python
One line Python

Algorithm (when applicable)

function BinarytoDecimal(int binaryNumber) -> int {
    constant string value = integer_to_string(binaryNumber)
    constant int length = length(value)
    variable int output = 0
    variable int position
    for 0 to length using position {
        variable character chr = char_from_string(value, position)
        if chr is '1' {
            output += 2^(length-1-position)
        } else if chr is '0' {
            continue loop
        } else {
            print("Make sure you only input binary values")
            exit(-1)
        }
    }
    return output
}

function starting_point(void) -> void {
    print("Binary Number: ")
    print(
        BinarytoDecimal(
            string_to_integer(
                get_user_input
            )
        )
    )
}