All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.qbicc.tests.snippets.MathMinMax Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
package org.qbicc.tests.snippets;// https://github.com/qbicc/qbicc/pull/219
import static org.qbicc.runtime.CNative.*;

public class MathMinMax {
    @extern
    public static native int putchar(int arg);

    public static void main(String[] args) {
        int i1 = 1;
        int i2 = 2147483647;
        int ib1 = Math.min(i1, i2);
        putchar(ib1 == 1 ? 'X' : 'F');
        int ib2 = Math.max(i1, i2);
        putchar(ib2 == 2147483647 ? 'X' : 'F');

        long l1 = 1;
        long l2 = 9223372036854775807L;
        long lb1 = Math.min(l1, l2);
        putchar(lb1 == 1 ? 'X' : 'F');
        long lb2 = Math.max(l1, l2);
        putchar(lb2 == 9223372036854775807L ? 'X' : 'F');

        float f1 = 1.0f;
        float f2 = 3.4028235E38f;
        float fb1 = Math.min(f1, f2);
        putchar(fb1 == 1.0f ? 'X' : 'F');
        float fb2 = Math.max(f1, f2);
        putchar(fb2 == 3.4028235E38f ? 'X' : 'F');

        double d1 = 1.0;
        double d2 = 1.7976931348623157E308;
        double db1 = Math.min(d1, d2);
        putchar(db1 == 1 ? 'X' : 'F');
        double db2 = Math.max(d1, d2);
        putchar(db2 == 1.7976931348623157E308 ? 'X' : 'F');
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy