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 2 1425
"Deano" <de*********@ho tmail.com> wrote in message
news:O7******** **********@ston es.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*1 2
from employees
--------------------------
I get 12,500 as expected.
John Winterbottom wrote: "Deano" <de*********@ho tmail.com> wrote in message news:O7******** **********@ston es.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*1 2 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 displays,
and I only reluctantly experiment with two-column layouts from time to
time.
One component of traditional book typography has always been the
figure/caption combination. I haven't been following discussion on
this topic for a year or...
|
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 decimal spots, but if it comes
up zeros, I would like to round to two spots after the last zero. I've
looked through google and haven't found anything I could use yet, so I
was wondering if you guys had any scripts or any leads I could use to
make...
|
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 price of item
field (say $49.95), and a percentage discount field (say 10% = $5.00),
and calculated net cost field of the two. Access seemingly doesn't
understand banker's rules as the resulting total is $44.96. Could this
be a bug? Why does it...
|
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
|
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
--
| |
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 seems to be done like this
3.435 = 3.44
3.445 = 3.44
Dim decNbr1 As Decimal
|
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
|
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)
It then updates the value with numberOfPrecisions after the decimal
|
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)
{
window.open(url,'win','scrollbars=1,status=0,resizable=0,width=200,height=265');
}
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |