function num_to_bin(
n number
)
return varchar2
is
binval varchar2(64);
n2 number := n;
begin
if (n == 0) then
return '0';
end if;
while (n2 > 0) loop
binval := mod(n2, 2) || binval;
n2 := trunc(n2 / 2);
end loop;
return binval;
end num_to_bin;
Hello,
ReplyDeletenice one thanks.
I have added something so it returns '0' instead of null when n = 0.
Thanks, I updated the code so it works for everyone. Cheers
Delete