decimal problem

From: Bert Prins (prinsoft_at_hotmail.com)
Date: 01/07/04


Date: Wed, 7 Jan 2004 12:23:40 +0100

Hello.

First: the best wishes for 2004 to all of you.

I have a problem with decimals.
I have two variables of the type Double. During the program the first
variable (fBtw) has the value 1724.725 and the second variable (fBruto)
10802.225. Then I converts both variables to strings with Format('%.2f',
variable):
sfBtw := Format('%.2f', [fBtw]); // -> 1724.72
sfBruto := Format('%.2f', [fBruto]); // -> 10802.23

Why, o why converts Format .725 to .72 and .225 to .23 ????? I tried it
under WinNT and Win2000 with the same result.
Is there a better way to convert a double with more than 2 decimals to a
double with 2 decimals?

Bert Prins



Relevant Pages

  • Re: decimal problem
    ... "Bert Prins" wrote in message ... > under WinNT and Win2000 with the same result. ... > double with 2 decimals? ... The problem is not in the rounding itself, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Decimals errors in reports
    ... If for some reason your underlying query returns the values as strings ... > to 2 digits for all fields, but some, not all, ... > truncated to two decimals, ...
    (microsoft.public.access.reports)
  • Re: storing number as string
    ... I happen to have some comma delim strings i want to put in a db ... convert to numbers to store in db ... datatype and 'strings' as string datatype. ... floating point - decimals. ...
    (microsoft.public.vb.database)
  • Re: storing number as string
    ... I happen to have some comma delim strings i want to put in a db ... convert to numbers to store in db ... datatype and 'strings' as string datatype. ... floating point - decimals. ...
    (microsoft.public.vb.database)
  • Re: Worlds Fastest Processor? For Now, Anyway
    ... Data-types representing character sets, character strings, packed ... Instructions for processing character strings in each data-type ... Instructions for converting among binary integers, packed decimals ...
    (comp.os.vms)