Skip to content

Instantly share code, notes, and snippets.

@bhalash
Last active December 15, 2016 11:58
Show Gist options
  • Save bhalash/a61539987c31d71305cce64755c60de6 to your computer and use it in GitHub Desktop.
Save bhalash/a61539987c31d71305cce64755c60de6 to your computer and use it in GitHub Desktop.
Numbers to Binary
const seconds = days => parseFloat(days) * 86400;
const milliseconds = seconds => parseFloat(seconds) * 1000;
const binary = milliseconds => (milliseconds >> 0).toString(2);
function compose(a, b) {
return function(c) {
return b(a(c));
}
}
function curry(a, val) {
return function(b) {
return a(val + b);
}
}
function add(number) {
const privateAdd = (a, b) => a + b;
return function(n) {
return privateAdd(number, n);
}
}
binary(milliseconds(seconds(24.85513481))); // "1111111111111111111111111111111"
binary(milliseconds(seconds(22))); // "1110001010010111110100000000000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment