Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a num2bin function #128

Open
3 tasks
martindsouza opened this issue Oct 9, 2016 · 1 comment
Open
3 tasks

Create a num2bin function #128

martindsouza opened this issue Oct 9, 2016 · 1 comment
Milestone

Comments

@martindsouza
Copy link
Member

martindsouza commented Oct 9, 2016

Example is in oos_util_totp.to_binary Changes to be made:

  • Expand the varchar2 from 8 to something much larger
  • Change the input from number to pls_integer since we're not handling decimals
  • How to handle negative numbers? leading bit?
function to_binary(p_num number) return varchar2
  is
    l_szbin varchar2(8);
    l_nrem number := p_num;
  begin
    if p_num = 0 then
      return '0';
    end if;

    while l_nrem > 0 loop
      l_szbin := mod(l_nrem, 2) || l_szbin;
      l_nrem := trunc(l_nrem / 2 );
    end loop;
    return l_szbin;
  end to_binary;
@martindsouza martindsouza added this to the Future milestone Oct 9, 2016
@zhudock
Copy link
Contributor

zhudock commented Jun 28, 2017

Duplicate of #67 ?

zhudock added a commit to zhudock/oos-utils that referenced this issue Dec 6, 2017
zhudock added a commit to zhudock/oos-utils that referenced this issue Dec 6, 2017
zhudock added a commit to zhudock/oos-utils that referenced this issue Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants