Skip to content

Instantly share code, notes, and snippets.

@butchi
Last active October 27, 2015 08:04
Show Gist options
  • Save butchi/f727c4f4b55f5e244413 to your computer and use it in GitHub Desktop.
Save butchi/f727c4f4b55f5e244413 to your computer and use it in GitHub Desktop.
JavaScriptのランプ関数いろいろ ref: http://qiita.com/butchi_y/items/36978607f95f8e5ccf91
function ramp(x) {
return (x < 0) ? 0 : x;
}
function ramp(x) {
return Math.max(x, 0);
}
function ramp(x) {
return ((Math.sign(x) + 1) / 2) * x;
}
function ramp(x) {
return Number(x.toString().replace(/^-.+/, 0));
}
function ramp(x) {
return Math.max(x, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment