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. 2 872
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/lib...nd(VS.80).aspx
I hope this helps,
Cor
"Agnes" <ag***@dynamictech.com.hk> schreef in bericht
news:OE**************@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.
--
Dennis 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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ordz |
last post by:
I want to write a program that will take a decimal with up to 4 places
and convert it to 1/16 ths. I can sort of do that with:
n = 375 * 16 / 1000
Print n; "/16"
I am planning to use an input...
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number....
|
by: Steve Summit |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
It's often explained that the reason for some of the imprecision
in C's definition is so that C can be implemented on different
kinds of machines -- say, those...
|
by: Kevin Chambers |
last post by:
Hi there--
I'm having a heck of a time trying to create a field of data type decimal.
It seems like, according to the docs, the following two statements should
work just fine:
ALTER TABLE...
|
by: Pieter |
last post by:
Hi,
I'm having some troubles with my numeric-types in my VB.NET 2005
application, together with a SQL Server 2000.
- I first used Single in my application, and Decimal in my database. But a...
|
by: Daniel |
last post by:
I'm writing an application that (among other things) evaluates
mathematical expressions. The user enters strings containing literals
and names that later get evaluated using the Python interpreter....
|
by: Laphan |
last post by:
Hi All
My ASP driven site has always used MySQL as the DB backbone, mainly as the
hosting costs of MySQL are far cheaper than SQL Server at the mo, and it has
worked fine until my ISP thought...
|
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= |
last post by:
Hi,
Why does Math.Sqrt() only accept a double as a parameter? I would think
it would be just as happy with a decimal (or int, or float, or ....). I can
easily convert back and forth, but I am...
|
by: Jason |
last post by:
I'm making a program that will convert decimal inputs (in this case, in
inches) and output a fractional answer. At the moment, I'm only able to
output the fractional answer in three parts: A whole...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |