TiddlyWiki5/editions/tw2/source/tiddlywiki/js/Numbers.js
2012-11-16 21:20:27 +00:00

15 lines
229 B
JavaScript
Executable file

//--
//-- Augmented methods for the JavaScript Number() object
//--
// Clamp a number to a range
Number.prototype.clamp = function(min,max)
{
var c = this;
if(c < min)
c = min;
if(c > max)
c = max;
return Number(c);
};