Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27383
Show key headers only | View raw
jonas.thornvall@gmail.com writes:
<snip>
> //CONVERT A DECIMAL NUMBER INTO ANYBASE
> function newbase(decNumber,base){
As before, both the comment and name are misleading. The number stored
in decNumber is not decimal any more than it is hexadecimal or octal.
This confusion is repeated in your recent question about the base or
operands.
The number is independent of any base used to represent it, but values
do have to be stored in computer programs and ECMAScript does this using
a binary floating point representation that is very tightly specified.
As a result, a comment like "convert a binary floating point number into
any base" would not be wrong, thought it still draw attention to a
matter that is of no consequence to the code. The function converts
numbers, however they may be represented internally, into your own
bignum representation.
> var out =[];
> digits=1;
> digmult=1;
> while(digmult*base<=decNumber){
> digmult=digmult*base
> digits++;
> }
I asked before why you do this rather than simply generate the digits is
the more natural, least-significant first, order but you never
explained.
> digsave=digmult;
> while(decNumber>0 || digits>=0){
> loop=1;
> digit=0;
> for (digit=0;digit<=base;digit++) {
> if((digit+1)*digmult>decNumber)break;
> }
This is an exceptionally inefficient way to find the digit. Have you
read up on any of the usual methods for doing what you are doing?
<snip>
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-09 22:26 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-09 22:44 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-09 22:59 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-09 23:02 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-09 23:16 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 01:49 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-10 11:53 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 06:33 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-10 20:25 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 11:55 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 04:05 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-11 13:13 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 04:49 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 04:56 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 05:31 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-11 20:22 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 12:07 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-11 21:32 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 13:22 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 16:07 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-12 12:06 +0200
Re: Convoluted logic trying to do bignumb Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-04-14 22:44 +0100
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-15 02:39 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-15 04:52 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-15 05:09 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-15 05:10 -0700
Re: Convoluted logic trying to do bignumb Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-15 22:46 +0100
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-16 01:06 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 07:21 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 08:06 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-11 20:32 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-11 12:10 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 06:55 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 07:19 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-10 07:26 -0700
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-12 07:20 -0700
Re: Convoluted logic trying to do bignumb "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-12 17:30 +0200
Re: Convoluted logic trying to do bignumb jonas.thornvall@gmail.com - 2015-04-12 09:03 -0700
csiph-web