How to force method using float instead of method with double?

0

How to force use the method with float instead of the double method?

public static void Dividir(double dividendo, double divisor)
{
    //https://www.codeproject.com/Tips/579137/Division-By-Zero-Doesnt-Always-Raise-An-Exception
    if (divisor == 0)
        throw new DivideByZeroException();
}

public static void Dividir(float dividendo, float divisor)
{
    var resultado = dividendo / divisor;
}

I want to call the method with float arguments how do I?

    
asked by anonymous 24.08.2018 / 18:48

1 answer

2

You need to call the method by passing floats by parameter, eg

float num1 = 1.1;
float num2 = 2.2;
Dividir(num1, num2);

If you already have the numbers and are not float , just give cast :

int num1 = 1.1;
int num2 = 2.2;
Dividir((float)num1, (float)num2);
    
24.08.2018 / 18:53