4

Possible Duplicate:
Create Excel (.XLS and .XLSX) file from C#
Rounding double values in C#

my double function generating values like this

  56,365989365

i want just value like this 56,36 how to get this ?

1

2 Answers 2

8

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);
Sign up to request clarification or add additional context in comments.

1 Comment

+1 from me for spotting the truncate.
2

Use Math.Round. The second argument is the number of places.

var x = Math.Round(56.365989365, 2);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.