Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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
Comments
Sergey Alexandrovich Kryukov 14-Jan-13 15:43pm    
I don't think you really need Round.
—SA

Hi,

.#### is max. 4 decimal places. Try .0000 instead:
C#
txtremaining.Text = rem.ToString(".0000");

Hope this helps.
 
Share this answer
 
Comments
ridoy 14-Jan-13 12:40pm    
+5
Thomas Daniels 14-Jan-13 12:41pm    
Thank you!
You can also handle only showing 4 decimal places in your Math.Round.

C#
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();
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900