Java Code Examples for java.math.BigInteger#floatValue()

The following examples show how to use java.math.BigInteger#floatValue() . These examples are extracted from open source projects. 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 Project: smallrye-graphql   File: FloatScalar.java    License: Apache License 2.0 6 votes vote down vote up
public FloatScalar() {

        super(Scalars.GraphQLFloat.getName(),
                new Converter() {
                    @Override
                    public Object fromBigDecimal(BigDecimal bigDecimal) {
                        return bigDecimal.floatValue();
                    }

                    @Override
                    public Object fromBigInteger(BigInteger bigInteger) {
                        return bigInteger.floatValue();
                    }

                },
                Float.class, float.class, Double.class, double.class);
    }
 
Example 2
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 3
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 4
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 5
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 6
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 7
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 8
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 9
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 10
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 11
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 12
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 13
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 14
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 15
public static int testFloatValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        float expected = Float.parseFloat(big.toString());
        float actual = big.floatValue();

        // should be bitwise identical
        if (Float.floatToRawIntBits(expected) != Float
                .floatToRawIntBits(actual)) {
            System.out.println(big + " " + expected + " " + actual);
            failures++;
        }
    }
    return failures;
}
 
Example 16
Source Project: gravel   File: LargeIntegerExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static float asFloat(BigInteger receiver) {
	return receiver.floatValue();
}
 
Example 17
Source Project: gravel   File: FloatExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static float differenceFromLargeInteger_(float receiver,
		BigInteger argument) {
	return argument.floatValue() - receiver;
}
 
Example 18
Source Project: gravel   File: FloatExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static float productFromLargeInteger_(float receiver,
		BigInteger argument) {
	return argument.floatValue() * receiver;
}
 
Example 19
Source Project: gravel   File: FloatExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static float quotientFromLargeInteger_(float receiver,
		BigInteger argument) {
	return argument.floatValue() / receiver;
}
 
Example 20
Source Project: gravel   File: FloatExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static float sumFromLargeInteger_(float receiver, BigInteger argument) {
	return argument.floatValue() + receiver;
}