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

De Documentação
(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...')
(Sem diferença)

Edição das 19h49min de 5 de agosto de 2023

Geração dos exemplos

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_baseh(bitstring,4,true) as b4h,
       natcod.vbit_to_baseh(bitstring,16,true) as b16h
FROM (
  SELECT bitstring, natcod.vbit_to_hbig(bitstring) x
  FROM natcod.generate_vbit_series(11) t(bitstring)
) t2) t3) t5 group by 1 order by 2 desc, 1;

Exemplo de comprimento 11

Distribuição dos comprimentos:

 len |  n   
-----+------
  11 | 2048
  10 | 1024
   9 |  512
   8 |  256
   7 |  128
   6 |   64
   5 |   32
   4 |   16
   3 |    8
   2 |    4
   1 |    2
(11 rows)

Distribuição dos valores sem diferenciador cache-length:

 value_dec | n  
-----------+----
         0 | 11
      1024 | 11
       512 | 10
      1536 | 10
       256 |  9
       768 |  9
      1280 |  9
      1792 |  9
       128 |  8
       384 |  8
       640 |  8
       896 |  8
      1152 |  8
      1408 |  8
      1664 |  8
      1920 |  8
        64 |  7
       192 |  7
       320 |  7
       448 |  7
       576 |  7
       ... | ...
      2012 |  3
      2020 |  3
      2028 |  3
      2036 |  3
      2044 |  3
         2 |  2
         6 |  2
        10 |  2
        14 |  2
        18 |  2
        22 |  2
       ... | ...
      2039 |  1
      2041 |  1
      2043 |  1
      2045 |  1
      2047 |  1
(2048 rows)