Hi,
I have a function that converts number to binary format which looks like
FUNCTION dec2bin (N in number, bits in number) RETURN varchar2 IS
binval varchar2(64);
N2 number := N;
BEGIN
while ( N2 > 0 ) loop
binval := mod(N2, 2) || binval;
N2 := trunc( N2 / 2 );
end loop;
binval := LPad(binval,bits,'0');
return binval;
END dec2bin;
I want to alter this so it works correctly for negative values as well. Please suggest.
Thanks,
Imran.