Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math

Topic: Is this radix bases?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
JT

Posts: 1,150
Registered: 4/7/12
Is this radix bases?
Posted: Jan 31, 2013 1:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

<HTML><HEAD><TITLE>TEST</TITLE>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
<SCRIPT language=Javascript>
function anybase() {
btwo=1;
bnr=0;
unr=0;
decimalnumber=document.doit.dnumb.value;
bas=document.doit.bval.value;
while (btwo<decimalnumber){
btwo=btwo*bas;
bnr++
}
basestring="";
while (decimalnumber>0){
unr++;
set=0;
for(i=bas;i>0;i--){
st=btwo*i;
if (decimalnumber>=st) {
decimalnumber=decimalnumber-st;
set=1;
basestring=basestring+i+",";
}
}
if(set==0 && decimalnumber!=0)basestring=basestring+0+",";
btwo=btwo/bas;
}
while (bnr>=unr){
basestring=basestring+0+",";
unr++;
}
radixout=basestring;
document.doit.radix.value=radixout;
control=document.doit.radix.value;
show=document.doit.dnumb.value+"=";
//Control Radix by go back to decimal
darr = control.split(",");
darr.reverse();
total=0;
multiple=1
for (i=1;i<darr.length;i++){
cval=darr[i];
cval=cval*multiple;
total=total+cval;
show=show+"("+multiple+"*"+darr[i]+")+";
multiple=bas*multiple;


}
document.doit.controlout.value=total;
document.doit.overview.value=show;
}

</SCRIPT>
<HTML><BODY>
<FORM NAME=doit onSubmit="anybase(); return false;">
CHANGE BASE:
<input type=submit value="GO!"><P>
DECIMAL VALUE:<TEXTAREA NAME=dnumb COLS=30
ROWS=1>777777777777</TEXTAREA><BR>
BASE:<TEXTAREA NAME=bval COLS=30
ROWS=1>333</TEXTAREA><BR>
RADIX OUT:<TEXTAREA NAME=radix COLS=200
ROWS=1></TEXTAREA><BR>

BACK TO DECIMAL CONTROL CONVERSION->
<TEXTAREA NAME=controlout COLS=30
ROWS=1></TEXTAREA><BR>
Radix HOWTO EXPLAIN<TEXTAREA NAME=overview COLS=200
ROWS=1></TEXTAREA><BR>

</FORM>
</BODY>
</HTML>



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.