Javascript Number mod( n )

Description

Javascript Number mod( n )


/**/*from  w  w w  .j  a  v  a  2s  . c  o  m*/
 * Taking the modulus of a negative number in JavaScript is wonky.
 * And we need to do exactly that (in IntervalVector). So here's a
 * workaround. Taken from here:
 *
 * http://javascript.about.com/od/problemsolving/a/modulobug.htm
 */
Number.prototype.mod = function( n ) {
 return ( ( this % n ) + n ) % n;
};



PreviousNext

Related