Enjoy an ad free experience by logging in. Not a member yet? Register.

Results 1 to 1 of 1

03022014, 03:08 AM #1
 Join Date
 Mar 2014
 Posts
 19
 Thanks
 0
 Thanked 0 Times in 0 Posts
Questions about my number bases program
/**I am making a program with different bases to show certain numbers starting with unary and going up to base 60 and seeing how that changes. */
background(0, 0, 0);
//unary
var inputnum = 10;
fill(255, 0, 0);
text(inputnum, 50, 50);
//binary
// number.toString( [ baseTo ] ); returns number in desired base.
(inputnum).toString(2);
fill(0, 0, 255);
text((inputnum).toString(2),50,60);
//ternary
(inputnum).toString(3);
fill(69, 201, 24);
text((inputnum).toString(3),50,70);
//Quarternary
(inputnum).toString(4);
fill(237, 151, 21);
text((inputnum).toString(4),50,80);
//Quinary
(inputnum).toString(5);
fill(122, 176, 51);
text((inputnum).toString(5),50,90);
//Senary
(inputnum).toString(6);
fill(0, 225, 255);
text((inputnum).toString(6),50,100);
//Septanary
(inputnum).toString(7);
fill(255, 0, 255);
text((inputnum).toString(7),50,110);
//Octal
(inputnum).toString(8);
fill(102, 0, 255);
text((inputnum).toString(8),50,120);
//Nonary
(inputnum).toString(9);
fill(242, 5, 159);
text((inputnum).toString(9),50,130);
shows numbers in base 10 as well as binary to nonary or base 2 to base 9.
Thats what I have so far.
I know up top is supposed to be the unary number or in another way a string of the same number of 1s as the number represents but this (number).toString(base) can't accept bases lower than binary or higher than base 36. How can I get both the unary and the bases above base 36 such as base 60?