Formatting Column of Times
Alex Tweedly
alex at tweedly.net
Wed Sep 7 14:44:55 EDT 2005
Dom wrote:
>
>another example: to make the sum of a field, and to yield a formatted
>result:
>
>on closefield
> put the short name of the target into tfield
> replace comma with "." in fld tfield
>-- european currency delimiter ;-)
> put fld tfield into montants
> replace return with comma in montants
> put "S" & tfield into ttotal
> put format("%3.2f",sum(montants)) into fld ttotal
>end closefield
>
>
>
"european currency delimiter" reminds me .... you need to be cautious
about using format for currency values.
Many countries (e.g. UK) have rules about how rounding should be
performed on currency values in some circumstances; this is typically
NOT the same method as used by Rev.
Rev will round as needed to the specified number of places after decimal
point (i.e. 2 in the code above). The rounding used is such that midway
values (i.e. exactly '5' in the following position) will round upwards
(e.g. 0.125 --> 0.13, 0.135 -> 0.14, etc.)
The UK rules on currency conversion required that for such "midway"
values you should always round to the even valued adjacent value (e.g.
0.125 -> 0.12, 0.135 -> 0.14) - which had the advantage of balancing out
the rounding amounts over a large enough set of values.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/90 - Release Date: 05/09/2005
More information about the use-livecode
mailing list