Skip to content

Infinity/NaN not supported #5

Open
@mrjameshamilton

Description

@mrjameshamilton

If you compile the following:

public class Test  {
    public static final float POSITIVE_INFINITY = Float.POSITIVE_INFINITY;
    public static final float NEGATIVE_INFINITY = Float.NEGATIVE_INFINITY;
    public static final float NaN = Float.NaN;
}

the disassembler produces the following:

version 1.8;
public class TestInf extends java.lang.Object [
    SourceFile "TestInf.java";
] {
    public static final float POSITIVE_INFINITY = ∞float;
    public static final float NEGATIVE_INFINITY = -∞float;
    public static final float NAN = NaNfloat;

    public void <init>() {
        line 1
            aload_0
            invokespecial java.lang.Object#void <init>()
            return
    }

    public static void main(java.lang.String[]) {
        line 8
            getstatic java.lang.System#java.io.PrintStream out
            ldc ∞float
            invokevirtual java.io.PrintStream#void println(float)
        line 9
            getstatic java.lang.System#java.io.PrintStream out
            ldc -∞float
            invokevirtual java.io.PrintStream#void println(float)
        line 10
            getstatic java.lang.System#java.io.PrintStream out
            ldc NaNfloat
            invokevirtual java.io.PrintStream#void println(float)
        line 11
            return
    }

}

This is because the conversion from number to string uses DecimalFormat here.

The assembler also cannot read this back in, since it cannot parse these constants (they aren't numbers).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions