BaseEx - Live Examples

Here you can find examples to demonstrate many features of BaseEx. You can run the code and also change it.
(Also check out the Online Base Converter)

In every example you have global access to the following constructors:


☛ Basic example

☛ Encoders handle almost every input

☛ Decoding returns an ArrayBuffer, but you can select from various types:

☛ Passing Arguments

propertyarguments
endiannessbele
paddingnopadpad
signunsignedsigned
caselowerupper
charset<various>
number-modenumber
decimal-modedecimal
IO handler
  • bytesIn
  • bytesOut
  • bytesInOut
>> accept only bytes as input
>> limits output to byte-like values
>> in- and output limited to bytes
output types
    Arguments can be passed to either en- and decoder or the constructor. The order or number of arguments does not matter. En- and decoder need the input as argument 0, anything else is not not predetermined.

    ☛ The BaseEx class holds ready to use instances of almost any available converter:

    ☛ Additional charsets can be added:

    ☛ Dealing with numbers (integers)

    There is much to say about numbers, actually too much to go into the details (you may want to read more here). BaseEx encoders always try to convert integers to the smallest fitting integer type (short, long, long long, double, n-bit-int) by default.
    Having said that, this is not what a JavaScript 'Number' is. JavaScript Numbers are always 64-bit floating points under the hood. With a last safe integer of 253-1. BaseEx can treat integers either way until the value of 253-1 is reached. After that, BigInts come into play and the byte representation will be the same for both modes.

    To visualize the byte conversion, no base conversion is getting used for this examples, but the ByteConverter.

    ☛ Dealing with decimals

    Yes, there are non integer bases, which can directly process rational and irrational numbers. Right now BaseEx has only BasePhi available. Every other converter is using the default conversion. If available, the decimal-mode must be specifically set with the decimal-Keyword.

    ☛ SimpleBase needs a radix from 2-62

    SimpleBase is a little special. It provides the simple mathematical base conversion as known from (n).toString(radix) and parseInt(n, radix).
    The constructor needs a radix between 2-62 as the first argument. In other regards it behaves as any other converter. (Which means, you can feed it with anything)

    Examples powered by:

    JSLiveExamples