Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
index.html

README.md

Description

This is a simple, standalone web page that contains a form which converts any base 10 positive integer into a base of your choosing. The base must be any base between 2 and 36, but Base64 is also supported due to its popularity. This page uses JQuery and the JQuery function that is added could easily be extracted into a plugin for modular use. The plugin works by you passing in:

  • The number to be converted
  • The base to convert to
  • a Success callback
  • an Error callback

Here is an example calling the plugin:

        $.baseToBase({
            base: $('#base').val(),
            number: $('#value').val(),
            success: function(output){
                $('.error').hide();
                $('#output').val(output);
            },
            error: function(error){
                $('.error').text(error).show();
            }
        });

Base System

Bases above 10 use the hexadeximal notation of capital A for 11, B for 12 and so on up to 36 (Z). Base64 uses a different system wherein the number 0 is represented by the letter A up to 25 being represented by Z. 26- 61 are represented by the lowercase alphanumerics (a-z). 62 is + and 63 is /

To illustrate, 11 in base 10 is B in base 16 and L in Base64.

Limitations

Very large numbers that need to be computed to smaller bases may result in an Overflow error which the plugin rightly handles by calling the error callback. Javascript's largest integer is 2^53, so if you provide a number more than twice that size and choose base 2, for example, the error callback will be triggered.

Something went wrong with that request. Please try again.