Skip to content

Instantly share code, notes, and snippets.

@akoluthic
Last active December 21, 2015 04:48
Show Gist options
  • Select an option

  • Save akoluthic/6251723 to your computer and use it in GitHub Desktop.

Select an option

Save akoluthic/6251723 to your computer and use it in GitHub Desktop.

Revisions

  1. @alexyoder alexyoder renamed this gist Aug 30, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @alexyoder alexyoder revised this gist Aug 30, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions js-log2
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@ function log2(val) {
    return Math.log(val) / Math.LN2;
    }

    //find the number of beams a musical note gets
    alert(log2(8) - 2); //8th notes get 1 beam
    alert(log2(128) - 2); //128th notes get 5 beams
    //find the number of flags a musical note gets
    alert(log2(8) - 2); //8th notes get 1 flag
    alert(log2(128) - 2); //128th notes get 5 flags
  3. @alexyoder alexyoder revised this gist Aug 30, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion js-log2
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,6 @@ function log2(val) {
    return Math.log(val) / Math.LN2;
    }

    alert(log2(128)); //alerts 7, as 128 is 2^7
    //find the number of beams a musical note gets
    alert(log2(8) - 2); //8th notes get 1 beam
    alert(log2(128) - 2); //128th notes get 5 beams
  4. akoluthic created this gist Aug 16, 2013.
    5 changes: 5 additions & 0 deletions js-log2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    function log2(val) {
    return Math.log(val) / Math.LN2;
    }

    alert(log2(128)); //alerts 7, as 128 is 2^7