class RealOperators {

    @ScalarOperator(CAST)
    @SqlType(StandardTypes.TINYINT)
    public static long castToTinyint(@SqlType(StandardTypes.REAL) long value)
    {
        float floatValue = intBitsToFloat((int) value);
        if (Float.isNaN(floatValue)) {
            throw new PrestoException(INVALID_CAST_ARGUMENT, "Cannot cast real NaN to tinyint");
        }
        try {
            return SignedBytes.checkedCast((long) MathFunctions.round((double) floatValue));
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + floatValue, e);
        }
    }

    private  RealOperators();

}