# Computerised Payroll Calculations

F

#### Frank X

Clive George said:
Well if you are talking about the transfer of money between different
entities it will always be integral. However if you are calculating value or
costs you will find a lot of prices are not integral the price of an
electronic component, a litre of petrol, a euro. Add to that the first thing
you do when calculating present value is discount using compound interest
rates, you know you are going to need to convert to a double anyway.
I've met people's code where they've done this. I've rewritten it too. It
worked much better afterwards.

For areas where you aren't concerned about the exact answer to the penny,
then this is ok (which you imply later). But if you're doing accounts, stick
to fixed point/integer arithmetic.

There are also a number of little rounding peculiarities that can happen
when using floating point, which means that no matter how precisely you
store your number, it can still go wrong in an unhelpful manner. Be very
careful!
If you need to round you need to round it doesn't matter how you store the
number.
Define finance Any system I'm involved in uses integral data - but then,
it's mostly accounting, not projections/estimates (1). Any programmer
involved with one of my systems who uses floating point except where
necessary will get severly told off!
In my case valuation in Investment Banking options, swaps, bonds, risk
management..
(1) Do you do things like the software for writing the pension forecasts?
I'd let that use doubles, but I'd expect the software that actually handles
my pension account to use integers.
How much has your pension dropped since 2000? The stuff I write is more like
what if scenarios. What if the FTSE goes up 20% what if interest rates go
up.

T

#### Tim

If you computer types ...
Are you trying to imply that I am a "computer type"?
If so, then what is that meant to mean? - if it is "uses a computer for his
job" then fair enough - I do. But I don't know of many accountants, lawyers
or any other professional people (including & particularly those in my
profession) who *don't* use computers!

If you are trying to imply that I am a programmer / systems analyst / etc,

... spent less time down the pub ...
I'm afraid I can't spend much *less* time down there!

... and more time at your desks ...
Ha ha - very funny. When was the last time you worked until 11 o'clock at
night?

... a byte would now have 16 bits!
Would that help with anything?!

Start concentrating on things
that matter computer types, rather than arguing about a penny with the
fuddy-duddy accountants!
I can argue about a penny as well as the next man - if it is important (and
yes, a lot of the time it may well not be important). I'm also quite
capable of arguing about the millions of pounds (or indeed, hundreds of
millions or more) - as I often have done in my job.

M

#### Matthew Church

Clive George said:
<gasp>

I've met people's code where they've done this. I've rewritten it too. It
worked much better afterwards.
So here we go again with the pedants wanting increasing levels of
accuracy at the fraction of a penny end, at the expense of speed and
capacity at the multiples of pounds end! But you will *never* satisfy
the pedants!

£
Motor expenses 1.50
Sundry expenses 1.50
----
3.00
====

I'm a pedant and I know Motor Expenses and Sundry Expenses are the
same this week. Round this into pounds for me.

P

C

#### Clive George

Matthew Church said:
"Clive George" <clive@xxxx-x.fsnet.co.uk> wrote in message

So here we go again with the pedants wanting increasing levels of
accuracy at the fraction of a penny end, at the expense of speed and
capacity at the multiples of pounds end! But you will *never* satisfy
the pedants!
I can assure you my code does not suffer from speed and capacity problems
due to my choice of data types. I explained why earlier, I also pointed out
that it is my job to know such things so other people (such as you) don't
£
Motor expenses 1.50
Sundry expenses 1.50
----
3.00
====

I'm a pedant and I know Motor Expenses and Sundry Expenses are the
same this week. Round this into pounds for me.
You're the client. You tell me.
Internally I would probably store these as integral pence, to avoid any
problems - that's my job, not yours.

In the absence of any specification from the client, I'd display 2, 2 and 3,
and when the client complained point out the inherent problems involved with
rounding. Ways round the problem include a means of displaying higher
precision (hover over figure, double click, user options) and as Peter's
already pointed out a display of the rounding errors incurred.

I am speaking from experience here by the way - eg I've just rewritten a
piece of code where the numbers were rounded before adding them up, which

(Actually your example is slightly harder than it initially appears, as in
some cases 1.50 shouldn't always be rounded to 2. But this is getting a bit
harder and like most of the rest of the world I tend to ignore this
problem - I just know it's there.)

clive

P

#### Peter Saxton

You're the client. You tell me.
Internally I would probably store these as integral pence, to avoid any
problems - that's my job, not yours.

In the absence of any specification from the client, I'd display 2, 2 and 3,
and when the client complained point out the inherent problems involved with
rounding. Ways round the problem include a means of displaying higher
precision (hover over figure, double click, user options) and as Peter's
already pointed out a display of the rounding errors incurred.

I am speaking from experience here by the way - eg I've just rewritten a
piece of code where the numbers were rounded before adding them up, which

(Actually your example is slightly harder than it initially appears, as in
some cases 1.50 shouldn't always be rounded to 2. But this is getting a bit
harder and like most of the rest of the world I tend to ignore this
problem - I just know it's there.)

clive
A client of mine was having a stock control/invoicing system progammed
and I told him how it should be tested and people try it out and
comment on it but he just had it done and running without anyone being
able to advise. It was a food company that, among other things made
muesli in various types. The programmer had taken prices from the
purchase invoices and then calculated the different purchase prices
and selling prices while totally ignoring rounding and just displayed
the invoices and reports to the nearest penny. The reports didnt add
up if you checked them manually and the invoices looked totally silly:

50 units at 2.00 per unit would be 99.75

The totals wouldnt add up and the VAT was wrong.

At least the client had the work done his way!

M

#### Matthew Church

Tim said:
Why does it need to be rounded into pounds?

If you put these numbers into Excel, and showed them to 0dp, you'd get:

ME 2
SE 2
No I wouldn't actually. Lotus 3.4 DOS forced calulating cells to
"look" right and I'm sure there is the same feature in Excel, though I
cannot be bothered to find it.

M

#### Matthew Church

Clive George said:
In the absence of any specification from the client, I'd display 2, 2 and 3,
and when the client complained point out the inherent problems involved with
rounding. Ways round the problem include a means of displaying higher
precision (hover over figure, double click, user options) and as Peter's
already pointed out a display of the rounding errors incurred.
No self-respecting pedant triggers an onmouseover event. They get
their PA's to print everything out so they have something to read on
the Tube.

M

#### Matthew Church

Tim said:
Ha ha - very funny. When was the last time you worked until 11 o'clock at
night?
The day I stopped being a pedant. Now I'm down the pub at 4.00pm with
the computer types. Cheers!!

S

#### Super Deluxe Sossidge Factry

bobve said:
hehehehhe
There is an age limit in here sonny [takes small child to back]

Child: [proudly] My mummy is in a room with the Committee! [indicates door]
SDSF: [Opens door ajar then sharply to] You can wait here till your Mum is finished!

T

#### Tiscali Stan

Super said:
bobve said:
hehehehhe
There is an age limit in here sonny [takes small child to back]

Child: [proudly] My mummy is in a room with the Committee! [indicates
door]
SDSF: [Opens door ajar then sharply to] You can wait here till your
Mum is finished!
There's another kid sitting over there, in blue, yonder.