473,382 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

decimal serious problem

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.



Apr 8 '06 #1
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.


Apr 8 '06 #2
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.



Apr 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
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...
17
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....
2
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...
6
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...
11
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...
3
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....
1
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...
13
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...
10
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...
1
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...
0
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...
0
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...
0
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,...
0
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$) { } ...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.