2
It is possible to convert "-12.0000"
(string) for -12.0000
(double) ?
Follows code:
var valor = "-12.0000";
var result = Convert.ToDouble(valor, CultureInfo.InvariantCulture); //-12 <--- perde zeros
Or if you prefer . NET Fiddle: https://dotnetfiddle.net/RnFB1f
I imagine you will use it differently, after all in this code the conversion is not necessary except for demonstration. Depending on how you use it needs to be quite different from this.
– Maniero
@Maniero It is possible to convert
"-12.0000"
(string) for-12.0000
(double) without losing the "0000". ?– Matheus Miranda
@Matheusmiranda Double is a type of data that stores values, not formatting for display, ie,
12.00000000000000
is the same thing as12
only, zeros are redundant, they alone are not a value and are not considered. This you want can be achieved with Tostring("0.0000"). Example:result.ToString("0.0000")
where the result variable is double.– MurariAlex
@Murarialex is what Murarialex said. Number follows mathematical rules, text is just drawing of the numbers you mount as you see fit.
– Maniero