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.independent

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
JT

Posts: 1,148
Registered: 4/7/12
Re: JS coding
Posted: Feb 4, 2013 12:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic 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>



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.