|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
decimal serious problemmyInvtable got a field named "invamt" which is decimail (9,2) ,
user will input the unitprice, noof unit in the table, and I will calculate the amount. in myInvDeatil_changed. ..... e.row("invamt") = e.row("unitprice") * e.row("noofunit") *E.row("exchangerate") When I use debugger to check, I found that e.row("invamt") = 4.875D <--- Why not 4.86 ???? Then, I try .. e.row("invamt") = Math.round(e.row("unitprice") * e.row("noofunit") *E.row("exchangerate") ,2) Me.InvAmt.text = Math.round(e.row("unitprice") * e.row("noofunit") *E.row("exchangerate") ,2) Debugger again, it sometimes return 4.87 , but sometimes return 4.86. I don't know what's wrong, please help. Agnes,
You are so long using this newsgroup. Your question has been often asked and the answer is forever, Net 1.x uses standard Banker's Rounding. In version 2.0 you can now use as well rounding as it is mostly done in the world. http://msdn2.microsoft.com/en-us/library/system.decimal.round(VS.80).aspx I hope this helps, Cor Show quoteHide quote "Agnes" <ag***@dynamictech.com.hk> schreef in bericht news:OEjBQlsWGHA.1220@TK2MSFTNGP02.phx.gbl... > myInvtable got a field named "invamt" which is decimail (9,2) , > > user will input the unitprice, noof unit in the table, and I will > calculate the amount. > in myInvDeatil_changed. > .... > e.row("invamt") = e.row("unitprice") * e.row("noofunit") > *E.row("exchangerate") > > When I use debugger to check, I found that e.row("invamt") = 4.875D <--- > Why not 4.86 ???? > Then, > I try .. e.row("invamt") = Math.round(e.row("unitprice") * > e.row("noofunit") *E.row("exchangerate") ,2) > Me.InvAmt.text = Math.round(e.row("unitprice") * > e.row("noofunit") *E.row("exchangerate") ,2) > Debugger again, it sometimes return 4.87 , but sometimes return 4.86. > I don't know what's wrong, please help. > > > > > > > Probably doesn't help but when I need to retain the exact decimal value, say
in a database, I save it as a string then convert it to decimal when I need to use it. -- Show quoteHide quoteDennis in Houston "Agnes" wrote: > myInvtable got a field named "invamt" which is decimail (9,2) , > > user will input the unitprice, noof unit in the table, and I will calculate > the amount. > in myInvDeatil_changed. > ..... > e.row("invamt") = e.row("unitprice") * e.row("noofunit") > *E.row("exchangerate") > > When I use debugger to check, I found that e.row("invamt") = 4.875D <--- > Why not 4.86 ???? > Then, > I try .. e.row("invamt") = Math.round(e.row("unitprice") * > e.row("noofunit") *E.row("exchangerate") ,2) > Me.InvAmt.text = Math.round(e.row("unitprice") * > e.row("noofunit") *E.row("exchangerate") ,2) > Debugger again, it sometimes return 4.87 , but sometimes return 4.86. > I don't know what's wrong, please help. > > > > > > > >
Save graphics image to bitmap?
Applications sharing Forms Authentication VB2005 -> OLEDB Connectivity question OptionExplicit programm crashs when instancing new object Retrieveing full Username from Enviroment? How do I get a gradualy changing colors? Form fade in Command line parameters Authicentication |
|||||||||||||||||||||||