Back to JS main page

DATE:1996-08-06


Binary:

Ternary:
Quintal:
Octal:
Decimal:
Hexadecimal:

COMMENTS:

Base Converter

Please note the following. Representation of a number in a system with base (radix) N may only consist of digits that are less than N.

More accurately, if

(1) M = akNk+ak-1Nk-1+...+a1N1+a0

with 0 <= ai < N we have a representation of M in base N system and write

M = (akak-1...a0)N

If we rewrite (1) as

(2) M = N*(ak+N*(ak-1+N*...))+a0

the algorithm for obtaining coefficients ai becomes more obvious. For example, a0=M modulo N and a1=(M/N) modulo N, and so on.

At one stage of conversion I use a built-in function parseInt which does not seem to return whenever this condition is violated by the very first digit. This appears to be a bug in the parseInt function. I am looking into this matter. For now, please follow the rule:

Representation of a number in a system with base (radix) N may only consist of digits that are less than N.


If you want this script just choose "Save Frame As..." (in Netscape) when you have the focus on the frame.

URL: http://www.oocities.org/SiliconValley/7116/jv_bin.html