當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript JSWLogger.warn方法代碼示例

本文整理匯總了TypeScript中jsw-logger.JSWLogger.warn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript JSWLogger.warn方法的具體用法?TypeScript JSWLogger.warn怎麽用?TypeScript JSWLogger.warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jsw-logger.JSWLogger的用法示例。


在下文中一共展示了JSWLogger.warn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: encodeFloat_

 /*
 encodeFloat_(data: string|number, precisionBits: number, exponentBits: number): string {
     var bias = maxBits[exponentBits - 1] - 1,
         minExp = -bias + 1,
         maxExp = bias,
         minUnnormExp = minExp - precisionBits,
         n = parseFloat(`${data}`),
         status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0,
         exp = 0,
         len = 2 * bias + 1 + precisionBits + 3,
         bin: Array<number> = new Array(len),
         signal: boolean = (n = status !== 0 ? 0 : n) < 0,
         intPart = Math.floor(n = Math.abs(n)),
         floatPart: number = n - intPart,
         lastBit,
         rounded,
         result,
         i,
         j;
 
 
     // for (i = len; i; bin[--i] = 0);
     i = len;
     while (i) {
         bin[--i] = 0;
     }
     
     // for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
     i = bias + 2;
     while (intPart && i) {
         bin[--i] = intPart % 2;
         intPart = Math.floor(intPart / 2);
     }
     
     // for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
     i = bias + 1;
     while (floatPart > 0 && i) {
         floatPart *= 2;
         bin[++i] = floatPart >= 1 ? 1 : 0;
         
         --floatPart;
     }
     
     // for (i = -1; ++i < len && !bin[i];);
     i = 0;
     while (i < len && !bin[i]) {
         i++;
     }
   
     if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp && 
             exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
         if (!(rounded = bin[lastBit])) {
             // for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
             j = lastBit + 2;
             while (!rounded && j < len) {
                 rounded = bin[j++];
             }
         }
         
         // for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
         j = lastBit;
         while (rounded && j >= 0) {
             j--;
             bin[j] = bin[j] ? 0 : 1;
             rounded = 0;
         }
     }
   
     for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
     
     if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
         ++i;
     } else if (exp < minExp) {
         exp != bias + 1 - len && exp < minUnnormExp && this.logger.warn("encodeFloat::float underflow");
         i = bias + 1 - (exp = minExp - 1);
     }
     
     if (intPart || status !== 0) {
         this.logger.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
         
         exp = maxExp + 1;
         i = bias + 2;
     
         if (status == -Infinity) {
             signal = true; // 1
         } else if (isNaN(status)) {
             bin[i] = 1;
         }
     }
   
     // for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
     n = Math.abs(exp + bias);
     j = exponentBits;
     result = "";
     while (j) {
         j--;
         result = (n % 2) + result;
         n = n >>= 1;
     }
     
//.........這裏部分代碼省略.........
開發者ID:EastolfiWebDev,項目名稱:MongoPortable,代碼行數:101,代碼來源:BinaryParser.ts

示例2: encodeFloat

    encodeFloat(data: /*string|*/number, precisionBits: number, exponentBits: number): string {
        var bias = maxBits[exponentBits - 1] - 1
            , minExp = -bias + 1
            , maxExp = bias
            , minUnnormExp = minExp - precisionBits
            //, n = parseFloat(_.toString(data))
			, n = data
            , status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0
            , exp = 0
            , len = 2 * bias + 1 + precisionBits + 3
            , bin = new Array(len)
            , signal = (n = status !== 0 ? 0 : n) < 0
            , intPart = Math.floor(n = Math.abs(n))
            , floatPart = n - intPart
            , lastBit
            , rounded
            , result
            , i
            , j;
        
        for (i = len; i; bin[--i] = 0);
        
        for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
        
        // for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
        for (i = bias + 1; floatPart > 0 && i; (bin[++i] = _.toNumber(((floatPart *= 2) >= 1)) ) && --floatPart);
        
        for (i = -1; ++i < len && !bin[i];);
        
        if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp && exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
            if (!(rounded = bin[lastBit])) {
                for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
            }
            
            // for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
            for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = _.toNumber(!bin[j])) && (rounded = 0));
            // j = lastBit + 1;
            // while (rounded && --j >= 0) {
            //     bin[j] = _.toNumber(!bin[j]);
            //     rounded = 0;
            // }
        }
        
        for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
        
        if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
            ++i;
        } else if (exp < minExp) {
            exp != bias + 1 - len && exp < minUnnormExp && this.logger.warn("encodeFloat::float underflow");
            i = bias + 1 - (exp = minExp - 1);
        }
        
        if (intPart || status !== 0) {
            this.logger.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
            exp = maxExp + 1;
            i = bias + 2;
            
            if (status == -Infinity) {
                signal = true;
            } else if (isNaN(status)) {
                bin[i] = 1;
            }
        }
        
        for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
        
        var r = [];
        for (n = 0, j = 0, i = (result = (signal ? "1" : "0") + result + bin.slice(i, i + precisionBits).join("")).length, r = []; i; j = (j + 1) % 8) {
            n += (1 << j) * result.charAt(--i);
            if (j == 7) {
                r[r.length] = String.fromCharCode(n);
                n = 0;
            }
        }
        
        r[r.length] = n
            ? String.fromCharCode(n)
            : "";
        
        return (this.bigEndian ? r.reverse() : r).join("");
    }
開發者ID:EastolfiWebDev,項目名稱:MongoPortable,代碼行數:81,代碼來源:BinaryParser.ts


注:本文中的jsw-logger.JSWLogger.warn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。