Interesting.  I got exactly the same results (6.1A) but when I changed the
data type of vDiff to CURRENCY, the rounding worked correctly.  Perhaps the
internal value is being stored as 14.49999999999999999999 or however many.

----- Original Message -----
From: Ramsour Mike <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 01, 2001 3:05 PM
Subject: Rounding question


> Comrades:
>
> I am trying to round a double data type to 4 decimal places.  Here is an
> example of the code I am testing:
>
> SET VAR VMAX DOUBLE = .032
> SET VAR VMIN DOUBLE = .0291
> SET VAR VDIFF DOUBLE = (((.VMAX - .VMIN) * 10000) / 2)
> SET VAR VAINT  = (AINT(.VDIFF))
> SET VAR VANINT = (ANINT(.VDIFF))
> SET VAR VINT   = (INT(.VDIFF))
> SET VAR VNINT  = (NINT(.VDIFF))
> SHOW VAR %INT%
>
> The intent is to find the difference between two numbers and determine
half
> of the result by either multiplying by .5 or dividing by 2.  I am raising
> the result by 10,000 so that I can use the ANINT function to round off the
> decimal point.
>
> The result of the third instruction above is 14.5.  According to the way I
> read the ANINT function the fifth instruction should give me an answer of
15
> since VDIFF is equal to 14.5.  The result I want is 15 but the answer I
get
> is 14 indicating that the value was rounded down.  I am not using the BRND
> function but it almost acts like it is.
>
> Is there something I'm missing or is there a better way to go about this?
>
> Version:  RBWIN 6.5++ on NT Workstation 4.0
>
> Thanks for your help.
>
> Mike Ramsour
> Technology Department
> AK Steel Coshocton Works
> 17400 SR 16
> Coshocton, OH  43812-0190
>
> Voice:  (740) 829-4340
> FAX  :  (740) 829-4211
>

Reply via email to