43261
![How to get short value using Double Function? [duplicate]](https://www.xszz.org/skin/wt/rpic/t9.jpg)
Question:
<blockquote>
<strong>Possible Duplicate:</strong><br /><a href="https://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp" rel="nofollow">Create Excel (.XLS and .XLSX) file from C#</a><br /><a href="https://stackoverflow.com/questions/2129804/rounding-double-values-in-c-sharp" rel="nofollow">Rounding double values in C#</a>
</blockquote>my double function generating values like this
56,365989365
i want just value like this 56,36
how to get this ?
Use Math.Round
. The second argument is the number of places.
var x = Math.Round(56.365989365, 2);
Answer2:If you want to trucate the value:
value *= 100;
value = Math.Truncate(value);
value /= 100;
If you want to round the value:
value = Math.round(value, 2);