[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Arithmetic compression.

JT

7/21/2014 8:26:00 PM

Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1

The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.

I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
38 Answers

JJ

7/21/2014 10:02:00 PM

0

On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
> Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.

Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?

JT

7/21/2014 10:45:00 PM

0

Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
> On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>
> > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> >
>
> > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> >
>
> > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
>
>
>
> Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?

"2*8=16"+"2*4=8"+"1*2=2"+"1*1=1" no it seem correct?

JT

7/21/2014 11:20:00 PM

0

Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
> On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>
> > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> >
>
> > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> >
>
> > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
>
>
>
> Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?

Here there is still bit a small bug, its hard to wrap head around but i will fix it. But it work flawless for some bases. I have an upgrade in mind going directly to bijective not via other bases.

JT

7/21/2014 11:22:00 PM

0

Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
> On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>
> > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> >
>
> > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> >
>
> > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
>
>
>
> Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?

Here is a generic basechanger still a small bug, its hard to wrap head around but i will fix it. But it work flawless for some bases. I have an upgrade in mind going directly to bijective not via other bases.

http://web.comhem.se/jonasth/bi...

JT

7/22/2014 6:17:00 AM

0

Den tisdagen den 22:e juli 2014 kl. 01:22:15 UTC+2 skrev jonas.t...@gmail.com:
> Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
>
> > On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>
> >
>
> > > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> >
>
> > >
>
> >
>
> > > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> >
>
> > >
>
> >
>
> > > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
>
> >
>
> >
>
> >
>
> > Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?
>
>
>
> Here is a generic basechanger still a small bug, its hard to wrap head around but i will fix it. But it work flawless for some bases. I have an upgrade in mind going directly to bijective not via other bases.
>
>
>
> http://web.comhem.se/jonasth/bi...

<html>
<HEAD><TITLE>Base Conversion</TITLE></HEAD>


<body bgcolor="gold" onLoad="main();">
<form name="rad" onSubmit="main(); return false;">
<table border="2" bgcolor="marineblue" width=1000><tr><td colspan="3" align="left">
Base/Radix <input type="text" name="base" value="3" size="6"><input type=submit value="Update Base!"><BR>
(N)umber range<input type="text" name="numbstart" value="16" size="6"> - <input type="text" name="numbend" value="200" size="6">

</td></tr>
<tr>
<th>Bijective Radix</th>
<th>Standard Radix</th>
<th>Standard 2nd Try</th>
</tr>
<tr><td colspan="1" align="left">
<textarea rows="80" name="bijective">
</textarea>
</td>
<td colspan="1" align="left">
<textarea rows="80" name="standard">
</textarea>
</td>
<td colspan="1" align="left">
<textarea rows="80" name="standtwo">

</textarea>
</form>
</td></tr>
</table>
</body>
</html>
<script type="text/javascript">

function encbase(number, bas)
{
basestr = "";
basemultip = 1;
digit = 0;
unr = 0;
while (basemultip < number)
{
basemultip = basemultip * bas;
digit = digit + 1;
}
while (number > 0)
{
unr ++ ;
set = 0;
for(i = bas; i > 0; i -- )
{
subtrahend = basemultip * i;
if (number >= subtrahend)
{
number = number - subtrahend;
set = 1;
basestr = basestr + i + " ";
}
}
if(set == 0 && number != 0)basestr = basestr + 0 + " ";
basemultip = basemultip / bas;
}
while (digit >= unr)
{
basestr = basestr + 0 + " ";
unr ++ ;
}
return basestr;
}


function enctwo(number, bas)
{
basestr = "";
basemultip = 1;
digit = 1;

while (basemultip < number)
{
basemultip = basemultip * bas;
digit = digit + 1;
}

while (number > 0 && digit > 0)
{
set = 0;
i = 0;
while (i * basemultip <= number && i < bas)
{
j = i;
i ++ ;
set = 1;
}
if (set == 1)
{
subtrahend = basemultip * j;
number = number - subtrahend;
basestr = basestr + j + " ";
}
//else if (set == 0 && number != 0)basestr = basestr + 0 + " ";
else {basestr = basestr + 0 + " ";}
basemultip = basemultip / bas;
digit -- ;
}
while (digit > 0)
{
basestr = basestr + 0 + " ";
digit -- ;
}
return basestr;
}



function bijenc(number, bas)
{
counter=0;
out = "";
var digits = ("" + number).split("").reverse();
length = digits.length;

while (counter < length)
{
if (digits[counter] == 0)
{
out = bas + " " + out ;
counter ++ ;
while (digits[counter] == 0)
{
out = (bas - 1) + " " + out;
counter ++ ;
}
if (digits[counter] > 1)
{
out = (digits[counter] - 1) + " " + out;
counter ++ ;
}
else
{
counter ++ ;
if(digits[counter] > 1)
{
out = bas + " " + out;
out = digits[counter] - 1 + " " + out;
counter ++ ;
}
else if(digits[counter] == 1)
{
while(digits[counter] == 1)
{
out = bas + " " + out;
counter ++ ;
}
}
}
}
else
while (digits[counter] > 0)
{
out = (digits[counter]) + " " + out;
counter ++ ;
}
}
return out;
}

function main()
{
dbase = document.rad.base.value;
dstart = document.rad.numbstart.value;
dend = document.rad.numbend.value;
strout = "";
strout2 = "";
strout3 = "";
for(x = dstart; x <= dend; x ++ )
{
strsave = encbase(x, dbase);
str = strsave.replace(/\s+/g, '');
str = parseInt(str, 10);
strsave2 = bijenc(str, dbase);
strsave = x + " = " + strsave;
strsave2 = x + " = " + strsave2;
strout2 = strout2 + "\n" + strsave2;
strout = strout + "\n" + strsave;
strsave3 = enctwo(x, dbase);
strsave3 = x + " = " + strsave3;
strout3 = strout3 + "\n" + strsave3;
}
document.rad.standard.value = strout;
document.rad.bijective.value = strout2;
document.rad.standtwo.value = strout3;
}
main();
</script>

John Harris

7/22/2014 8:07:00 AM

0

On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com
wrote:

>Encoding binary numbers into base-2 zeroless encoding save digit
>places why isn't it used is there disadvantages doing arithmetic in
>zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
<snip>

It's not used because transistors can represent 0 and 1 in a
non-analogue way. To represent 0, 1, and 2 you have to go analogue
with the resulting noise, drift, etc. problems.

In other words, binary is much more robust; greater than binary is
fragile or has to use more transistors to do the job.

John

Stefan Weiss

7/22/2014 9:58:00 AM

0

On 2014-07-22 10:07, John Harris wrote:
> On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com
> wrote:
>
>>Encoding binary numbers into base-2 zeroless encoding save digit
>>places why isn't it used is there disadvantages doing arithmetic in
>>zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
> <snip>
>
> It's not used because transistors can represent 0 and 1 in a
> non-analogue way. To represent 0, 1, and 2 you have to go analogue
> with the resulting noise, drift, etc. problems.

The bijective binary notation doesn't use zeros, only 1s and 2s.

> In other words, binary is much more robust; greater than binary is
> fragile or has to use more transistors to do the job.

Setun seemed to manage ternary just fine ;)

I guess one of the reason why the bijective notation isn't used for
digital calculations is that there is no obvious way to represent the
value 0 with on-off states.

- stefan

J. Clarke

7/22/2014 11:28:00 AM

0

In article <0a07b248-1bfa-49bb-8cb1-ba0b11f6d2e0@googlegroups.com>,
jonas.thornvall@gmail.com says...
>
> Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
> > On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
> >
> > > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
> >
> > >
> >
> > > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
> >
> > >
> >
> > > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
> >
> >
> >
> > Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?
>
> "2*8=16"+"2*4=8"+"1*2=2"+"1*1=1" no it seem correct?

Then represent 26 in your system without using a zero.


JT

7/22/2014 11:50:00 AM

0

Den tisdagen den 22:e juli 2014 kl. 10:07:10 UTC+2 skrev John Harris:
> On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com
>
> wrote:
>
>
>
> >Encoding binary numbers into base-2 zeroless encoding save digit
>
> >places why isn't it used is there disadvantages doing arithmetic in
>
> >zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> <snip>
>
>
>
> It's not used because transistors can represent 0 and 1 in a
>
> non-analogue way. To represent 0, 1, and 2 you have to go analogue
>
> with the resulting noise, drift, etc. problems.
>
>
>
> In other words, binary is much more robust; greater than binary is
>
> fragile or has to use more transistors to do the job.
>
>
>
> John

I think either you or I missed the point John, 2211 is only a representational technicality. In reality you would store it as 1100 or 0011, both systems 2-radix not three, they only use two symbols it is the encoding circuit decoding circuit that makes the difference.

JT

7/22/2014 11:53:00 AM

0

Den tisdagen den 22:e juli 2014 kl. 13:27:37 UTC+2 skrev J. Clarke:
> In article <0a07b248-1bfa-49bb-8cb1-ba0b11f6d2e0@googlegroups.com>,
>
> jonas.thornvall@gmail.com says...
>
> >
>
> > Den tisdagen den 22:e juli 2014 kl. 00:01:50 UTC+2 skrev JJ:
>
> > > On Mon, 21 Jul 2014 13:26:27 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>
> > >
>
> > > > Encoding binary numbers into base-2 zeroless encoding save digit places why isn't it used is there disadvantages doing arithmetic in zeroless bases? 27 = 1 1 0 1 1 = 2 2 1 1
>
> > >
>
> > > >
>
> > >
>
> > > > The actual numbers in example is of course just symbols we could encode it to 1100? And with a bijective zeroless encoder decode it would still decode to 27.
>
> > >
>
> > > >
>
> > >
>
> > > > I have a much stronger compressed encoding in mind, if is just implement it correct it will be mindblowing.. I hope this get thru i am not always that clear, presenting my problems.
>
> > >
>
> > >
>
> > >
>
> > > Shouldn't that be: 1 1 0 1 1 = 2 2 1 2 2 ?
>
> >
>
> > "2*8=16"+"2*4=8"+"1*2=2"+"1*1=1" no it seem correct?
>
>
>
> Then represent 26 in your system without using a zero.

2122 = 2*8 + 1*4 + 2*2 + 1*2 = 26
Please look at the script.