Re: [Slightly OT] Dealing with fractions of cents
- From: "Kuldeep" <kuldeep.vijaykumar@xxxxxxxxxxx>
- Date: Wed, 6 Sep 2006 22:12:32 +0530
How about using Math.RoundOff
"Chris Dunaway" <dunawayc@xxxxxxxxx> wrote in message
news:1157550900.287805.30530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am writing a simple point of sale type application. One of the
functions includes reading a weight from a scale and then multiplying
that weight by a UnitPrice to get an amount.
The scale returns its weight in pounds to 3 decimal places. We then
take this weight and multiply by the unit price per pound which is
$3.20.
Sometimes, I get total amounts that have more than 2 decimal places.
For example, if the scale reads .995 lbs and I multiply by the unit
price os $3.20, the result is $3.184.
When a transaction is entered into the transactions table, using a
money column, the value is stored unrounded (i. e. as 3.184).
I use the Decimal data type in C# so this works out fine.... sort of.
Inevitably on printed reports, sometimes the sums of the values are off
by a penny or two. This seems to be due to a rounding of the actual
values to 2 decimal places.
I am looking for a way to handle smoothly so that calcuations and
reports agree.
Does anyone have any algorithms or advice on a simple way to handle
this type of situation?
Thanks,
Chris
.
- Follow-Ups:
- Re: [Slightly OT] Dealing with fractions of cents
- From: Steve Barnett
- Re: [Slightly OT] Dealing with fractions of cents
- References:
- [Slightly OT] Dealing with fractions of cents
- From: Chris Dunaway
- [Slightly OT] Dealing with fractions of cents
- Prev by Date: Re: Oracle AQ
- Next by Date: Re: Dealing with fractions of cents
- Previous by thread: Re: Dealing with fractions of cents
- Next by thread: Re: [Slightly OT] Dealing with fractions of cents
- Index(es):
Relevant Pages
|