Mike, Bill: I always define my variables as currency when using them in computations. The original question was posted by Mike Sinclair and I just mentioned that this issue was discussed 2 or 3 months ago as I remember running this type of calculation through other programs (excel) to compare results. It was my understanding that it had been submitted as a bug.
The partial text of the previous thread (10/11/2002) is as follows: ======================================================== Tom: I am running the latest patch. I ran the enclosed code and it is not truncating, it is rounding incorrectly. The value of vRawTaxAmt = 50.43 / 11. = 4.58454545... After the third line the values shows as 4.59 where the correct rounded value (TTBOMK) at 2 decimal; places should be 4.58; if the value would be truncated it would actually show 4.58. I have tried several variations with the same result. At 3 decimal places the correct rounded value should be 4.585 but a t 2 decimal places it should be 4.58. I wonder if the function incorrectly does a sequential rounding starting from the right and rounds 5.585 to 5.59, this would be incorrect. You can verify this easily by plugging the numbers into an excel spreadsheet and displaying the result formatted with 3 and 2 decimal places, the results will be 4.585 and 4.58 not 4.59. So, in short, as far as I can tell, the ROUND function rounds the value incorrectly. You should do the honors and submitted to the RDDC. Javier Valencia, PE President Valencia Technology Group, L.L.C. 14315 S. Twilight Ln., Suite #14 Olathe, KS 66062-4571 (913)829-0888 (913)649-2904 FAX -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Tom Grimshaw Sent: Friday, October 11, 2002 10:07 PM To: [EMAIL PROTECTED] Subject: Rounding Issue G'day, I appear to have a rounding issue with 6.5++ (latest beta). Is it just me or can anyone else confirm that this number appears to be being truncated rather than rounded please? SET VAR vAmtToRound CURRENCY = 50.43 SET VAR vRawTaxAmt DOUBLE = (.vAmtToRound / 11) SET VAR vCurTaxAmt DOUBLE = (ROUND(.vRawTaxAmt,2)) SET VAR vCurTaxAmt CURRENCY SHO VAR Warmest regards, Tom Grimshaw ================================================ I hope this is of help. Javier Javier Valencia, PE President Valencia Technology Group, L.L.C. 14315 S. Twilight Ln., Suite #14 Olathe, KS 66062-4571 (913)829-0888 (913)649-2904 FAX -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Bill Downall Sent: Monday, February 10, 2003 6:57 AM To: RBASE-L Mailing List Subject: [RBASE-L] - RE: Rounding with Currency Javier, This is not the same as the other rounding issues that have been discussed. Your problem stems from the very low precision available in the REAL data type. You should use DOUBLE. I would also recommend that you do your computations in the DOUBLE datatype, then cast that answer into currency, rather than rounding directly into currency: -- this works: SET V v1 CURRENCY = 11 SET V v2 DOUBLE = .83 SET V v3 CURRENCY SET V v3 = (.v1 * .v2 * 1.5) -- = 13.70 -- this works, and gives you better protection against -- data type conversion precision problems SET V v1 CURRENCY = 11 SET V v2 DOUBLE = .83 SET V v4 DOUBLE SET V v4 = (.v1 * .v2 * 1.5) SET VAR v3 CURRENCY SET VAR v3 = (.v4) Bill On Sun, 9 Feb 2003 23:12:43 -0600, Javier Valencia wrote: >Using REAL numbers (instead of currency) as follows& > >(11 * .83 * 1.5) = 13.695, which should round up to $13.70. > >

