org.jf.util.NumberUtils Java Examples

The following examples show how to use org.jf.util.NumberUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionMethodItem.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected void writeCommentIfLikelyFloat(IndentingWriter writer, int val) throws IOException {
    if (NumberUtils.isLikelyFloat(val)) {
        writer.write("    # ");
        float fval = Float.intBitsToFloat(val);
        if (fval == Float.POSITIVE_INFINITY)
            writer.write("Float.POSITIVE_INFINITY");
        else if (fval == Float.NEGATIVE_INFINITY)
            writer.write("Float.NEGATIVE_INFINITY");
        else if (fval == Float.NaN)
            writer.write("Float.NaN");
        else if (fval == Float.MAX_VALUE)
            writer.write("Float.MAX_VALUE");
        else if (fval == (float)Math.PI)
            writer.write("(float)Math.PI");
        else if (fval == (float)Math.E)
            writer.write("(float)Math.E");
        else {
            writer.write(Float.toString(fval));
            writer.write('f');
        }
    }
}
 
Example #2
Source File: InstructionMethodItem.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected void writeCommentIfLikelyDouble(IndentingWriter writer, long val) throws IOException {
    if (NumberUtils.isLikelyDouble(val)) {
        writer.write("    # ");
        double dval = Double.longBitsToDouble(val);
        if (dval == Double.POSITIVE_INFINITY)
            writer.write("Double.POSITIVE_INFINITY");
        else if (dval == Double.NEGATIVE_INFINITY)
            writer.write("Double.NEGATIVE_INFINITY");
        else if (dval == Double.NaN)
            writer.write("Double.NaN");
        else if (dval == Double.MAX_VALUE)
            writer.write("Double.MAX_VALUE");
        else if (dval == Math.PI)
            writer.write("Math.PI");
        else if (dval == Math.E)
            writer.write("Math.E");
        else
            writer.write(Double.toString(dval));
    }
}