Compression of digital function sharing using the transform of the system

Source: Internet
Author: User

  This article mainly introduces the conversion function, used to compress the number, such as Date.now () such a long number, with 62 in the system, it is shorter, we refer to the use of the bar

The code is as follows: function zipnum (num, radix) {    if (!zipnum.zip) {        Zipnum.zip = function (input Num) {            if (Inputnum > 35) {//In uppercase letter 36-61           &NB Sp     return String.fromCharCode (' A '. charCodeAt (0) + inputnum% 36);            } else if (Inputnum > 9) {///in lowercase letter 10-35           &NB Sp     return String.fromCharCode (' a '. charCodeAt (0) + inputnum% 10);            } else {                return Inputnum ;                     {   }     var quotient = num , remainder, result;     if (Radix > && radix <) {      result = [];       &N Bsp Do {            remainder = quotient% radix;nbsp           quotient = parseint (Quotient/radix);             Result.push (zipnum.zip (remainder));        }while (quotient > Radix);         remainder = quotient% radix;         if (remainder!== 0) {            Result.push (Zipnum.zip Remainde R));        }         result = Result.reverse (). Join (");    } else if (Radix > 1 && Radix <) {      result = num.tostring (radix);    } else {        result = num;         Window.console && con Sole.warn (' radix argument must be between 2 ")    }     return result; }   function Testsortnum () {    assertequals (Zipnum (), ' Z ');     Assertequals (Zipnum (62 * 2 -1, the ' 1Z ');     AssertequaLS (zipnum (3-1), ' 2Z ');     Assertequals (Zipnum (1361182624991,), ' DXN5FJB '); } testsortnum ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.