Microsoft KB Archive/77341

= FIX: Incorrect Results with PARAMETER in NINT =

Article ID: 77341

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q77341



SYMPTOMS
Programs that contain a PARAMETER constant in an arithmatic expression within the NINT intrinsic function argument list may generate incorrect results during run time.



RESOLUTION
One way to work around this problem is to use a variable in the expression instead of a PARAMETER.



STATUS
Microsoft has confirmed this to be a problem in the products listed above. This problem was corrected in FORTRAN PowerStation.



MORE INFORMATION
The following code can be sued to reproduce the problem:

Sample code
integer*4 iconst parameter (iconst = 1024)

real sdata, ddata

ddata = 200.0 sdata = 0.001 c       iconst = 1024

c incorrect results generated here print *, 'NINT(ddata * iconst * sdata) * 2 = ', * NINT(ddata * iconst * sdata) * 2 print *, 'NINT(ddata * iconst * 0.001) * 2 = ', * NINT(ddata * iconst * 0.001) * 2

print *, 'NINT(200.0 * iconst * sdata) * 2 = ', * NINT(200.0 * iconst * sdata) * 2 print *, 'NINT(200.0 * iconst * 0.001) * 2 = ', * NINT(200.0 * iconst * 0.001) * 2

print *, 'NINT(ddata    * iconst * sdata) + 2 = ', * NINT(ddata * iconst * sdata) + 2 print *, 'NINT(ddata    * iconst * 0.001) + 2 = ', * NINT(ddata * iconst * 0.001) + 2

END Output: NINT(ddata * iconst * sdata) * 2 =      409  ! this value should be 410 NINT(ddata * iconst * 0.001) * 2 =      410 NINT(200.0 * iconst * sdata) * 2 =      410 NINT(200.0 * iconst * 0.001) * 2 =      410 NINT(ddata * iconst * sdata) + 2 =      207 NINT(ddata * iconst * 0.001) + 2 =      207

Additional query words: 5.00 5.10 buglist5.00 buglist5.10 fixlist1.00

Keywords: KB77341

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.