Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27475
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Overflow, integers and strings |
| Date | Sun, 03 May 2015 16:45:09 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 75 |
| Message-ID | <87lhh5zmuy.fsf@bsb.me.uk> (permalink) |
| References | <e7aac5c2-b226-44f4-a77f-fa284c3877ba@googlegroups.com> <09495c64-e320-46ca-a6d9-b9f0427c7efd@googlegroups.com> <66061bf2-9092-42a5-918e-5a039a53db20@googlegroups.com> <XnsA48C8AB5EE74Ceejj99@194.109.133.246> <6ca07e69-1694-49c1-93eb-748c44d8ab68@googlegroups.com> <XnsA48CD1D512C3Beejj99@194.109.133.246> <b378aebc-5acc-4b88-9050-6b812221cba9@googlegroups.com> <XnsA48D6DDF66B5Feejj99@194.109.133.246> <871tj08vrb.fsf@bsb.me.uk> <XnsA48D942F1A7FFeejj99@194.109.133.246> <mhvtku$rh2$1@solani.org> <1997740.h7VUlrh2Em@PointedEars.de> <mi0rm4$d4a$1@solani.org> <XnsA48E35CB52B7eejj99@194.109.133.246> <72e44d34-7f4d-4d32-8304-e73688132274@googlegroups.com> <3770518e-e91f-4368-9a69-cbd2f2461343@googlegroups.com> <a446b186-9ac4-410d-846d-3b2406a0bfd2@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="18236"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19u0yNwT0sWoZi4ij9glmcaelH8du+HQiI=" |
| Cancel-Lock | sha1:yjkACyIuzEG0u5NkdJz8thHLyeg= sha1:eV4NEeFU0Oigo80gBIxKl0wAKHY= |
| X-BSB-Auth | 1.b7a2f029d2a84741f556.20150503164509BST.87lhh5zmuy.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:27475 |
Show key headers only | View raw
jonas.thornvall@gmail.com writes:
<snip>
Why did you quote over 450 lines of a previous post? Please trim you
quotes.
> If someone wants to change newbase into a bignumb function all the
> necessary functions there. For a skilled programmer probably no more
> than 10 lines of code.
>
> <SCRIPT LANGUAGE="Javascript">
>
> /*CONVERT A DECIMAL NUMBER INTO ANYBASE */
>
> function newbase(decNumber,base){
'decNumber' is not a decimal number. Both the name and the comment are
wrong.
> var out =[];
> digits=1;
global
> digmult=1;
global
> while(digmult*base<=decNumber){
> digmult=digmult*base
> digits++;
> }
> digsave=digmult;
global
> while(decNumber>0 || digits>=0){
> loop=1;
global
> digit=0;
global
> for (digit=0;digit<=base;digit++) {
> if((digit+1)*digmult>decNumber)break;
> }
> out[digits]=digit;
> digmult=digmult*digit;
> decNumber=decNumber-digmult;
> digsave=digsave/base;
> digmult=digsave;
> digits--;
> }
> if(out[0]==0) out.splice(0,1);
> return out;
> }
What about
function newbase(num, base)
{
var digits = [];
do {
digits.push(num % base);
num = Math.floor(num / base);
} while (num);
return digits;
}
? This is the usual way to to it.
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 00:11 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 01:29 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:31 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:33 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 13:38 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 08:20 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 20:37 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 23:46 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:01 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:50 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 02:04 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 11:08 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:43 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:48 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 10:58 +0100
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:34 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:47 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 15:04 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:18 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:24 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 11:27 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 12:34 -0700
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-01 22:42 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 23:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-02 00:19 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-02 05:50 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-02 14:21 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 04:30 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 07:12 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-03 16:45 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:22 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 03:38 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 14:01 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:41 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:39 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:48 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:25 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:26 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:59 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:59 +0100
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:28 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:34 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:41 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:52 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:03 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 17:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:04 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:38 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:07 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:25 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:43 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:11 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:53 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:23 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:12 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:39 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:42 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:30 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 23:33 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 15:53 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:51 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 18:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:22 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 21:38 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 14:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:19 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:24 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 21:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:21 -0700
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 22:38 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:46 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 22:57 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:17 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:45 +0100
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-06 00:01 +0200
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-05 08:14 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-05 23:54 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 23:18 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:53 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 16:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-05 10:26 +0200
Re: Overflow, integers and strings Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-05-05 19:59 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:40 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 01:10 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 05:03 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-30 20:36 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 13:08 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-04-30 10:52 -0700
csiph-web