Discussão:Código Natural/Representação interna: mudanças entre as edições

(Criou página com ' == Geração dos exemplos == <syntaxhighlight lang="sql"> select len, count(*) n from (select len, bitstring, hbig as hbig_dec, '0 '||((hbig-len)>>4)::bit(11)::text ||' ' ||len::bit(4)::text internal_16bits, hbig>>4 as value_dec, len as len_dec from (SELECT row_number() over() AS count, bitstring, -- x as hbig, natcod.vBit_to_hSml( bitstring ) as hbig, length(bitstring) as len, natcod.vbit_to_hiddenBig( bitstring ) as hidd, natcod.vbit_to_b...')
 
Linha 3: Linha 3:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
select len, count(*) n from (select len, bitstring, hbig as hbig_dec, '0 '||((hbig-len)>>4)::bit(11)::text ||' ' ||len::bit(4)::text internal_16bits, hbig>>4 as value_dec, len as len_dec from (SELECT row_number() over() AS count, bitstring,
create view wiki_print1 AS
SELECT len,  
      bitstring,  
      hbig as hbig_dec,
      '0 '||((hbig-len)>>4)::bit(11)::text ||' ' ||len::bit(4)::text internal_16bits,
      hbig>>4 as value_dec,
      len as len_dec
FROM (
  SELECT row_number() over() AS count, bitstring,
       -- x as hbig,
       -- x as hbig,
       natcod.vBit_to_hSml( bitstring ) as hbig, length(bitstring) as len,
       natcod.vBit_to_hSml( bitstring ) as hbig, length(bitstring) as len,
Linha 9: Linha 17:
       natcod.vbit_to_baseh(bitstring,4,true) as b4h,
       natcod.vbit_to_baseh(bitstring,4,true) as b4h,
       natcod.vbit_to_baseh(bitstring,16,true) as b16h
       natcod.vbit_to_baseh(bitstring,16,true) as b16h
FROM (
  FROM (
  SELECT bitstring, natcod.vbit_to_hbig(bitstring) x
    SELECT bitstring, natcod.vbit_to_hbig(bitstring) x
  FROM natcod.generate_vbit_series(11) t(bitstring)
    FROM natcod.generate_vbit_series(11) t(bitstring)
) t2) t3) t5 group by 1 order by 2 desc, 1;
  ) t1
) t2;
</syntaxhighlight>
</syntaxhighlight>
 
<pre>
len |  bitstring  | hbig_dec |  internal_16bits  | value_dec | len_dec
-----+-------------+----------+--------------------+-----------+---------
  1 | 0          |        1 | 0 00000000000 0001 |        0 |      1
  2 | 00          |        2 | 0 00000000000 0010 |        0 |      2
  3 | 000        |        3 | 0 00000000000 0011 |        0 |      3
  4 | 0000        |        4 | 0 00000000000 0100 |        0 |      4
  5 | 00000      |        5 | 0 00000000000 0101 |        0 |      5
  6 | 000000      |        6 | 0 00000000000 0110 |        0 |      6
  7 | 0000000    |        7 | 0 00000000000 0111 |        0 |      7
  8 | 00000000    |        8 | 0 00000000000 1000 |        0 |      8
  9 | 000000000  |        9 | 0 00000000000 1001 |        0 |      9
  10 | 0000000000  |      10 | 0 00000000000 1010 |        0 |      10
  11 | 00000000000 |      11 | 0 00000000000 1011 |        0 |      11
  11 | 00000000001 |      27 | 0 00000000001 1011 |        1 |      11
  10 | 0000000001  |      42 | 0 00000000010 1010 |        2 |      10
  ...
</pre>
=== Exemplo de comprimento 11 ===
=== Exemplo de comprimento 11 ===
Distribuição dos comprimentos:
Distribuição dos comprimentos:
<pre>
<pre>
select len, count(*) n from wiki_print1 group by 1 order by 2 desc, 1;
  len |  n   
  len |  n   
-----+------
-----+------
Linha 36: Linha 63:
Distribuição dos valores sem diferenciador cache-length:
Distribuição dos valores sem diferenciador cache-length:
<pre>
<pre>
select value_dec, count(*) n from wiki_print1 group by 1 order by 2 desc, 1;
  value_dec | n   
  value_dec | n   
-----------+----
-----------+----
2 583

edições