Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,2 @@
SELECT n, format('{:b}', n)
FROM (select unnest(range(0, 6) || [50, 9000]) as n);

View file

@ -0,0 +1,22 @@
# n is assumed to be a non-negative integer
CREATE OR REPLACE FUNCTION binary_digits(n) as (
WITH RECURSIVE cte(num, str) as (
-- Base case
SELECT n, ''
UNION ALL
-- Recursive case: divide by 2 and build the binary string
SELECT num // 2, (num % 2) || str
FROM cte
WHERE num > 0
)
SELECT CASE WHEN str = '' THEN '0' ELSE str END
FROM cte
WHERE num = 0
LIMIT 1
);
select n, binary_digits(n)
from (select unnest(range(0, 6) || [50, 9000]) as n);
.maxwidth 200
select n, binary_digits(n) from (select 123456789123456789123456789123456789 as n)