Awk cheatsheet

From Lolly's Wiki
Revision as of 11:36, 14 October 2016 by Lollypop (talk | contribs) (Die Seite wurde neu angelegt: „ ==Functions== ===Binary to decimal=== <source lang=awk> function b2d(bin){ len=length(bin); for(i=1;i<=len;i++){ dec+=substr(bin,i,1)*2^(len-i); }…“)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Functions

Binary to decimal

function b2d(bin){
  len=length(bin);
  for(i=1;i<=len;i++){
    dec+=substr(bin,i,1)*2^(len-i);
  }
  return dec;
}