Here you can find the source of toRoman()
//var colors = ["blue","red","black","yellow"]; //console.log(colors[2]); //var i = 0/*w ww .j a v a 2 s.co m*/ //for(i=0; i<477; i++) { // console.log(i); //} //function plusTwo (x) { // return x+2; //} //console.log(plusTwo(2)); //function timesTwo (x) { // return 2*x; //} //console.log(timesTwo(2)); Number.prototype.toRoman= function () { var num = Math.floor(this), val, s= '', i= 0, v = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1], r = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']; function toBigRoman(n) { var ret = '', n1 = '', rem = n; while (rem > 1000) { var prefix = '', suffix = '', n = rem, s = '' + rem, magnitude = 1; while (n > 1000) { n /= 1000; magnitude *= 1000; prefix += '('; suffix += ')'; } n1 = Math.floor(n); rem = s - (n1 * magnitude); ret += prefix + n1.toRoman() + suffix; } return ret + rem.toRoman(); } if (this - num || num < 1) num = 0; if (num > 3999) return toBigRoman(num); while (num) { val = v[i]; while (num >= val) { num -= val; s += r[i]; } ++i; } return s; };
'use strict' Number.prototype.toRadians = function() { return this * Math.PI / 180;
Number.prototype.toRadians = function() { return (this.valueOf() * Math.PI) / 180;
function toReadableFileSize(bytes) { var i = 0; var byteUnits = [' bytes' , ' kB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB']; while (bytes > 1024) { bytes = bytes / 1024; i++; if (i > 0) return bytes.toFixed(1) + byteUnits[i]; ...
assert = require("assert"); Number.prototype.toRoman = (function () { var nmap = { M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1 }; var toRomanR = function toRomanR(num) { for (var a in nmap) { if (nmap[a] <= num) { return a + toRomanR(num - nmap[a]); ...
$(document) function() { Number.prototype.toRoman= function () { var num = Math.floor(this), val, s= '', i= 0, v = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1], r = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']; function toBigRoman(n) { var ret = '', n1 = '', rem = n; while (rem > 1000) { ...
Number.prototype.degToRad = function () { return this.valueOf() / 180 * Math.PI;
Number.prototype.inRadians = function() { return this * Math.PI / 180.0;
Number.prototype.inRange = function (a, b) { var value = this.valueOf(); return (value >= a) && (value <= b); };