Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27383

Re: Convoluted logic trying to do bignumb

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Convoluted logic trying to do bignumb
Date 2015-04-15 22:46 +0100
Organization A noiseless patient Spider
Message-ID <878udthxpf.fsf@bsb.me.uk> (permalink)
References (14 earlier) <XnsA47A7B204A77Beejj99@194.109.133.246> <xX1U+YxyoYLVFwwy@invalid.uk.co.demon.merlyn.invalid> <21469d11-c489-49f9-a4ea-ff3a56bab507@googlegroups.com> <31f09d6b-6684-4300-935e-316921f2dae3@googlegroups.com> <8909f1dc-882f-41cf-b335-fafc624b0ac3@googlegroups.com>

Show all headers | 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


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