Hi,

Th String maths routines (SDIV, SMULT etc) that Martin alludes to at the 
bottom of his post are very effective, but do require code changes to all 
the calcuations in the program.

You can achieve the same effect in Universe by putting $OPTIONS 
STRING.MATH at the top of the program.

However, there may be other reasons for getting rounding errors. 

For example, if you have a an invoice for a number of items and you wish 
to calculate the tax on that invoice, you can do this one of two ways. You 
can calculate and round the tax on each item and then add up the 
individual tax amounts. Or you can add up the value of the items and 
calculate and round the tax on the total value. The two methods can give 
different figures.

I know most people in the list will be familiar with that scenario but 
sometimes it is worth making sure that the obvious issues are covered 
before looking for something more unusual.

cheers,

asvin


> 
> The problem here is that, just as there are numbers that cannot be 
> represented accurately in decimal such as 1/3, there are numbers that 
cannot 
> be represented accurately in the binary notiation used by the computer. 
As 
> an easy example, the number 0.2 cannot be represented accurately and 
ends up 
> as something like 0.20000000000000001 as a close approximation. Because 
IEEE 
> floating point has a limited number of bits to store the matissa part of 
the 
> value, the whole thing scales with bigger numbers. Essentially, a number 

> cannot have lots of significant figures, wherever they may be in 
relation to 
> the decimal point.
> 
> If you add up a large number of figures with these rounding errors they 
may 
> accumulate to something significant. Even worse, if you decide to do 
decimal 
> scaling with a simple multiply instead of an MD conversion code, the 
> inaccuracies get scaled too.
> 
> This problem is not unique to UniVerse. It is a well known probelm of 
> floating point numbers in computer systems. The usual fix in the 
multivalue 
> world is to scale numbers (dollars to cents, for example) so that all 
our 
> numbers are integers. UV also provides a set of character string 
arithmetic 
> functions if you really want to get clever.
> 
> 
> Martin Phillips
> Ladybridge Systems Ltd
> 17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
> +44-(0)1604-709200 
> -------
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/


************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for 
a new issue, by investment clients of the firm for whom the Bank as a firm 
already provides other services. It may equally decide to allocate to its 
own proprietary book or with an associate of HSBC Group. This represents a 
potential conflict of interest. HSBC Bank plc has internal arrangements 
designed to ensure that the firm would give unbiased and full advice to 
the corporate finance client about the valuation and pricing of the 
offering as well as internal systems, controls and procedures to identify 
and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority.
************************************************************


-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to