package expression.generic;

/**
 * @author Doschennikov Nikita (me@fymio.us)
 */
public class FloatType implements ArithmeticType<Float> {

    public static final FloatType INSTANCE = new FloatType();

    private FloatType() {}

    @Override
    public Float fromInt(int value) {
        return (float) value;
    }

    @Override
    public Float add(Float a, Float b) {
        return a + b;
    }

    @Override
    public Float subtract(Float a, Float b) {
        return a - b;
    }

    @Override
    public Float multiply(Float a, Float b) {
        return a * b;
    }

    @Override
    public Float divide(Float a, Float b) {
        return a / b;
    }

    @Override
    public Float negate(Float a) {
        return -a;
    }

    @Override
    public Float count(Float a) {
        return (float) Integer.bitCount(Float.floatToIntBits(a));
    }

    @Override
    public Float min(Float a, Float b) {
        return Math.min(a, b);
    }

    @Override
    public Float max(Float a, Float b) {
        return Math.max(a, b);
    }
}
