Base converter shortcode WordPress plugin

A plugin to convert numbers in base 10 to other number bases, including their decimal places. You can insert this into pages and posts with a shortcode:

[​base no="NUMBER" base="BASE TO CONVERT TO" prec="DECIMAL PLACES" show="SHOW BASE AS INDEX"​]

  • no is a real number, decimal places are set off by a dot, so a valid input is e.g. 12.3456.
  • base is the base you want to convert to as an integer, e.g. 12.
  • prec is an integer number that defines how many places you want after the decimal point. If you leave this out, the number returned will have the same number of places after the dot as the input. A valid input would be e.g. 3.
  • show is a boolean value, i.e. either 0 for ‘no’ or 1 for ‘yes’, that enables or disables showing the base of the result as an index after it, like 10A₁₂. If you leave this out, 0 will be assumed.

For example, the following codes gives the following result:

[​base no="1234" base="2" show="1"​]
10011010010₂

[​base no="123.4567" base="16" show="0"​]
7B.74EA

The script can also round up or down:

[​base no="0.142857" base="12" prec="20"]
0.186A348718B4610B5534

The same, shortened to 3 places:
[​base no="0.142857" base="12" prec="3"​]
0.187

The same, shortened to 5 places:
[​base no="0.142857" base="12" prec="5"​]
0.186A3

Download