12,450,605 members (51,358 online)
Rate this:
See more:
```Double total = Convert.ToDouble(dt.Rows[0]["Amount_with_markup"]);
Double paid = Convert.ToDouble(txtpaid.Text);
Double rem =Math.Round(total - paid);
txtremaining.Text = rem.ToString(".####");```
Posted 14-Jan-13 6:06am
Sergey Alexandrovich Kryukov 14-Jan-13 15:43pm

I don't think you really need Round.
—SA

Rate this:

## Solution 1

Hi,

`.####` is max. 4 decimal places. Try `.0000` instead:
```txtremaining.Text = rem.ToString(".0000");
```
Hope this helps.
ridoy 14-Jan-13 12:40pm

+5
ProgramFOX 14-Jan-13 12:41pm

Thank you!
Rate this:

## Solution 2

You can also handle only showing 4 decimal places in your Math.Round.

```Double total = Convert.ToDouble(20.04353450);
Double paid = Convert.ToDouble(19.25641654);
Double rem = Math.Round(total - paid, 4, MidpointRounding.AwayFromZero);
txtremaining.Text = rem.ToString();```
ridoy 14-Jan-13 12:40pm

+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 ppolymorphe 139 Richard MacCutchan 120 OriginalGriff 95 Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ) 50 David_Wimbley 45
 OriginalGriff 5,988 Karthik Bangalore 3,500 ppolymorphe 3,471 Maciej Los 3,005 Richard Deeming 2,805

Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 14 Jan 2013