Java 类org.mozilla.javascript.v8dtoa.FastDtoa 实例源码

项目:TaleCraft    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:code404    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:rhino-jscover    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:LoboEvolution    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:astor    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:Rhino-Prov-Mod    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:android-js    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (d != d)
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:closure-compiler-old    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (Double.isNaN(d))
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}
项目:es6draft    文件:AbstractOperations.java   
private static String ToStringSlow(double value) {
    // call DToA for general number-to-string
    String result = FastDtoa.numberToString(value);
    if (result != null) {
        return result;
    }
    StringBuilder buffer = new StringBuilder();
    DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, value);
    return buffer.toString();
}
项目:closure-compiler-copy    文件:ScriptRuntime.java   
public static String numberToString(double d, int base) {
    if (Double.isNaN(d))
        return "NaN";
    if (d == Double.POSITIVE_INFINITY)
        return "Infinity";
    if (d == Double.NEGATIVE_INFINITY)
        return "-Infinity";
    if (d == 0.0)
        return "0";

    if ((base < 2) || (base > 36)) {
        throw Context.reportRuntimeError1(
            "msg.bad.radix", Integer.toString(base));
    }

    if (base != 10) {
        return DToA.JS_dtobasestr(base, d);
    } else {
        // V8 FastDtoa can't convert all numbers, so try it first but
        // fall back to old DToA in case it fails
        String result = FastDtoa.numberToString(d);
        if (result != null) {
            return result;
        }
        StringBuilder buffer = new StringBuilder();
        DToA.JS_dtostr(buffer, DToA.DTOSTR_STANDARD, 0, d);
        return buffer.toString();
    }

}