@Round @Text error

I am experiencing strange results when I convert ‘certain’ numbers to text after rounding them.

I have a view which is used for exporting a fixed width text file to a Unix based database.

I have to ensure that the vat value is 11 characters long and has two decimal places even if it is a whole number.

I do this by:

  • rounding the number to 2 decimal places,

  • multiply it by 100

  • convert it to text.

I then pass this into a formula that adds the relevant no of 0’s on the front.

— If the Inv_Vat = 4.64

(This is just the part that causes the error the full formula is shown at the end)

rnd := @Round( Inv_VAT ; 0.01);

@Text( rnd *100)

An answer of “463.999999999999” is returned, instead of “464”

The same problem arises with the following values

36.12

67.35

I cannot see any pattern to these numbers causing the problem.

This worked fine in version 5.0.x and only started happening after we upgraded to ver 6.0.0 (and 6.0.1 & cf1).

Now as you can imagie importing “9999999999.99” instead of “0000000004.64” is causing our accounts package a major problem

“Full formula showing conversion to fixed length.”

iv:= @Round(Inv_VAT;0.01);

vv :=@Text(@Right(“00000000000” + @Text( iv * 100) ; 10));

@Left(vv ; 8) + “.” + @Right(vv ; 2)

Any help would be appreciated, as I can’t see a work around as at some point i’ll have to convert a rounded number to text and risk getting the same error.

regards

chris page

Subject: Try doing it a different way…

rnd := @Round( Inv_VAT * 100; 0);@Text(rnd)

It is unfortunate, but certain floating point numbers can not be represented in binary even after they are “Rounded”. By multiplying by 100 first, you will remove the error.

Subject: @Round @Text error

I have no solution for you, but Lotus is aware of this problem …

You may wan to look in this thread too