Awk cheatsheet: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
(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); }…“)
 
No edit summary
Line 12: Line 12:
}
}
</source>
</source>
[[Kategorie:AWK]]

Revision as of 11:36, 14 October 2016

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;
}

Kategorie:AWK