RosettaCodeData/Task/Bitwise-IO/DuckDB/bitwise-io-1.duckdb
2025-08-11 18:05:26 -07:00

8 lines
262 B
Text

# s should be a bitstring.
# Right-pad s with 0s so that the length of the output string is a multiple of 8.
CREATE OR REPLACE FUNCTION print_bits(s) as (
format('{:0<{}}', s, (ceil(length(s) / 8) * 8)::INT)
);
# Example:
select print_bits('101'::BITSTRING);