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


Groups > comp.lang.javascript > #27314

Re: Convoluted logic trying to do bignumb

Newsgroups comp.lang.javascript
Date 2015-04-11 05:31 -0700
References (5 earlier) <8cd3a812-f346-4af0-97c7-62f02cd2264a@googlegroups.com> <XnsA478CFBC0C88Ceejj99@194.109.133.246> <c43e9f32-7cac-4a1c-a670-06bd01ff6743@googlegroups.com> <XnsA479868525BDAeejj99@194.109.133.246> <79c50d33-33c7-4ff9-9a8d-29a2af3ee97b@googlegroups.com>
Message-ID <58540d8e-94a6-4e9b-914e-e18050dc2abd@googlegroups.com> (permalink)
Subject Re: Convoluted logic trying to do bignumb
From jonas.thornvall@gmail.com

Show all headers | View raw


Den lördag 11 april 2015 kl. 13:56:56 UTC+2 skrev jonas.t...@gmail.com:
> Den lördag 11 april 2015 kl. 13:13:30 UTC+2 skrev Evertjan.:
> > jonas.thornvall@gmail.com wrote on 11 apr 2015 in comp.lang.javascript:
> > 
> > > Once one realise that base also should be in Array, things start to get
> > > really convoluted, because also the add, multiplication and subtraction
> > > must start use compare instead of straightforward loops. 
> > > 
> > > The ugly solution would be to make base to an Array just at the function
> > > calls needing it as an array (the compare) the digitVal is already an
> > > Array because it was needed for add and multiply. 
> > 
> > Perhaps not practical, but certainly beautiful,
> > would be to make all functions into re-entrant black boxes,
> > having only local variables, 
> > but for the input-parameters and the return value.
> > 
> > That means you could write a whole programme in any base.
> > 
> > -- 
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
> 
> A nice start moving into free base arithmetic, would be if Javascript allowed comparissons of total array size while loops, for loops and if comparissons.
> 
> I find it annoying needing to do this for every loop and comparisson.
> 
> // If A < B returns true otherwise false
> function arrCompare(A, B, smaller)
> {
>    if(A.length > B.length)
>    {
>       smaller = "false";
>    }
>    else if(A.length == B.length)
>    {
>       for(i = A.length-1; i >=0; i -- )
>       {
>          if(A[i] < B[i])
>          {
>             smaller = "true"
>          }
>          else
>          {
>             smaller = "false"
>          }
>       }
>    }
>    return smaller;
> }
> 
> Although i have no idea about the work needed it for be done, i can certainly see the use for it.

But then one probably also would like to compare a value in an array with the full array? And if base would be an array?

How would one do a single integer compare to array if (addResult[i] >= base)
So know addResult[i] would also have to be an array within the array.

Things get convoluted... One can cheat by doing a new split into array but..., well i think i cheat.

But why does things end up like this, maybe because there is no unique representation of the bignumber digits?

The base digitplace has to be broken down into decimal digits, with their own index within array?

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