Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: JS coding
Replies: 27   Last Post: Feb 24, 2013 6:17 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 JT Posts: 1,448 Registered: 4/7/12
Re: JS coding
Posted: Feb 4, 2013 12:07 AM
 Plain Text Reply

On 4 Feb, 05:47, JT <jonas.thornv...@gmail.com> wrote:
> On 3 Feb, 23:33, Virgil <vir...@ligriv.com> wrote:
>
>
>
>
>
>
>
>
>

> > In article
> > <6e315bac-9f19-4cee-ad90-7ec7bbe8b...@w7g2000yqo.googlegroups.com>,

>
> >  JT <jonas.thornv...@gmail.com> wrote:
> > > I do not want a counter, i want a general solution to re encode any
> > > decimal number where anybase(decimal,base) {}
> > > This is probably why people save code instead of posting it to
> > > usenet ;D

>
> > The process involves repeated divisions with whole number quotients and
> > remainder
> >  Example: Convert 99 base 10 to base 8

>
> > Step 1.  8 into 99 goes 12 times with 3 left over
> > Step 2.  8 into 12 goes 1  time  with 4 left over
> > Step 3.  8 into  1 goes 0  times with 1 left over
> > Stop when base goes into dividend 0 times

>
> > Then line up the leftovers from last to first: 1,4,3
>
> > Result 99(base 10) is 143(base 8)
>
> > Check: 143(base 8) = 1*8^2 + 4*8^1 + 3*8^0
> >                    = 1*64  + 4*8   + 3*1
> >                    =   64  + 32    + 3
> >                    =   99  (base 10)
> > --

>
> This is creepy it seem like google do something with the code that
> make it impossible to run.
> I posted elswhere works! Go to my facebook page copy code paste save
> as HTML and run.http://www.facebook.com/jonas.thornvall

<HTML><HEAD><TITLE>TEST</TITLE>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
<SCRIPT language=Javascript>
function anybase(bas,decimal) {

multip=0;
basemultip=1;
unr=0;
basestr="";
subtrahend=0;

while (basemultip<decimal){
basemultip=basemultip*bas;
multip=multip+1;
}
while (decimal>0){
unr++;
set=0;

for(i=bas;i>0;i--){
subtrahend=basemultip*i;
document.write(subtrahend+"="+basemultip+"* (i)"+i
+"<BR>");

if (decimal>=subtrahend) {
document.write("decimal"+decimal+"-
subtra"+subtrahend);
decimal=decimal-subtrahend;
document.write("="+decimal+"<BR>")
set=1;
basestr=basestr+i+",";

}

}

if(set==0 && decimal!=0)basestr=basestr+0+",";
basemultip=basemultip/bas;

}
while (multip>=unr){
basestr=basestr+0+",";
unr++;

}
document.write("basestr "+basestr+"<BR>");

}
anybase(4,81);
</SCRIPT>
<HTML>

Date Subject Author
2/3/13 JT
2/3/13 JT
2/3/13 JT
2/3/13 Virgil
2/3/13 JT
2/3/13 JT
2/3/13 JT
2/3/13 JT
2/3/13 JT
2/4/13 JT
2/6/13 JT
2/6/13 Virgil
2/6/13 JT
2/7/13 JT
2/10/13 JT
2/10/13 Virgil
2/22/13 JT
2/23/13 Virgil
2/23/13 JT
2/23/13 JT
2/23/13 JT
2/24/13 JT
2/23/13 JT
2/6/13 JT
2/6/13 JT
2/6/13 JT
2/3/13 JT
2/3/13 JT

© The Math Forum at NCTM 1994-2018. All Rights Reserved.