Skip to content

Instantly share code, notes, and snippets.

@ploosh-alt
Last active May 11, 2022 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ploosh-alt/8db0e6f5960fdba8bcece4515c2993ce to your computer and use it in GitHub Desktop.
Save ploosh-alt/8db0e6f5960fdba8bcece4515c2993ce to your computer and use it in GitHub Desktop.
binary function in js
b=(i)=>{let n=i<0,s="",d=(n?(-i):i)/2,p;for(;d>0.49;d/=2){p=parseInt(d);s+=d==p?"0":"1";d=p};return(n?"-":"")+"0b"+s.split("").reverse().join("")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment