Last active
December 21, 2015 04:48
-
-
Save akoluthic/6251723 to your computer and use it in GitHub Desktop.
Javascript - Determine power of 2 (log2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function log2(val) { | |
return Math.log(val) / Math.LN2; | |
} | |
//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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment