473,503 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a2k - rounding of figures, comments?

One thing that slightly annoys me about my app is a side-affect from the way
it processes figures. It calculates salaries very precisely (to the penny)
but there are rounding issues that cause figures to differ a few pence.
This then affects some reports - my main report might differ from the
detailed reports (which pick up their data from different fields in the same
table) by anything up to 10 pence.

I suppose it's crazy to worry about but for me it would be nice finishing
touch to sort this out (all the reports should tally exactly). I will give
you the main scenario in which this happens;

Someone selects a salary point for an employee. It's worth £12,500. This
is recorded in a field and shown on the form.
Next this figure is divided up into 12 months and again these figures are
recorded on the table and on the form.

£12,500/12 = £1041.67 per month

At a later stage I may need to multiply up these months but this gives me
£12500.04. This is the crux of the problem. The calculation code can be
quite complex and I always knew this might happen but I'm determined to fix
it.

The fix is to put code in that performs this calculation and then makes the
adjustments to as many months as is required.
e.g in this case I would adjust the first four months figures downward by a
penny each. So when the 12 months are combined I get the total figure of
£12,500 exactly.

I'm going to work this out myself, mainly because my problem is so specific
to my application but wondered if anyone's got any general remarks about
this kind of problem or have had similar experiences.

ta
Martin
Nov 13 '05 #1
2 1415
"Deano" <de*********@hotmail.com> wrote in message
news:O7******************@stones.force9.net...

Someone selects a salary point for an employee. It's worth £12,500. This
is recorded in a field and shown on the form.
Next this figure is divided up into 12 months and again these figures are
recorded on the table and on the form.

£12,500/12 = £1041.67 per month

At a later stage I may need to multiply up these months but this gives me
£12500.04. This is the crux of the problem. The calculation code can be
quite complex and I always knew this might happen but I'm determined to fix it.


Are you sure you're using a money data type? When I do this:

----------------------------
create table employees
(
empID int not null primary key,
salaryPoint money not null,
monthlySalary money null
)

insert into employees ( empID, salaryPoint )
values(1, 12500)

updateemployees
set monthlySalary = salaryPoint/12

select empID, monthlySalary*12
from employees
--------------------------

I get 12,500 as expected.


Nov 13 '05 #2
John Winterbottom wrote:
"Deano" <de*********@hotmail.com> wrote in message
news:O7******************@stones.force9.net...

Someone selects a salary point for an employee. It's worth £12,500.
This is recorded in a field and shown on the form.
Next this figure is divided up into 12 months and again these
figures are recorded on the table and on the form.

£12,500/12 = £1041.67 per month

At a later stage I may need to multiply up these months but this
gives me £12500.04. This is the crux of the problem. The
calculation code can be quite complex and I always knew this might
happen but I'm determined to fix it.


Are you sure you're using a money data type? When I do this:

----------------------------
create table employees
(
empID int not null primary key,
salaryPoint money not null,
monthlySalary money null
)

insert into employees ( empID, salaryPoint )
values(1, 12500)

updateemployees
set monthlySalary = salaryPoint/12

select empID, monthlySalary*12
from employees
--------------------------

I get 12,500 as expected.


Cheers John, you've got me thinking. I'm going to play with my datatypes
and see what happens.
Nov 13 '05 #3

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

Similar topics

6
6188
by: Robert J. O'Hara | last post by:
I'm one of those people who practices what some consider "dull" and others consider "elegantly conservative" page design. I appreciate good traditional typography and standards-compliant liquid...
10
1779
by: joshb | last post by:
Hey guys, I have a length converter which converts mm, cm, m, km, ft, yd, in and mi. If I convert 5mm to miles, I get 0.00000031068559649... miles. I'm looking to convert all my values to two...
3
9372
by: Dalan | last post by:
Is there any code available to address currency rounding problems in Access 97? Apparently, selecting currency type table fields does not resolve the problem. For instance, in my form I have a...
1
15461
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
20
15855
by: Daisy | last post by:
Something simple, I'm sure. My code: System.Windows.Forms.MessageBox.Show(((Int32)Math.Ceiling(1966 / 100)).ToString()); I'm expecting 20, but getting 19. What am I doing wrong? Thanks --
11
6620
by: cj | last post by:
Lets assume all calculations are done with decimal data types so things are as precise as possible. When it comes to the final rounding to cut a check to pay dividends for example in VB rounding...
10
2147
by: alsmeirelles | last post by:
Hi all, I Have run this test: Private Sub test() Dim d As Double Dim f As Single Dim output As String d = 8888888888888.8887
206
13093
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
16
1902
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi All, I have a neat little script that calculates price based on quantity without refreshing the page.. the script is - <script type="text/javascript"> function OpenWin(url) {...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.