Pregunta

I have a bunch of code written by someone else for a statistics package, like so:

float myValue = 0.0f;

That makes myValue a single point precision number. Is there a way to make it go to five decimal places?

Is this the correct way:

 float myValue = 0.00000f;
¿Fue útil?

Solución

f is to specify the value is float

From msdn : By default, a real numeric literal on the right side of the
assignment operator is treated as double. Therefore, to initialize a float
variable, use the suffix f or F

Both declarations are the same. If you want round to five decimal point by using Math.Round()

Math.Round(45.45672234, 5);
Ans : 45.45672
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top