FIX: Incorrect Results with PARAMETER in NINT

ID: Q77341

5.00 5.10 | 5.00 5.10 MS-DOS | OS/2 kbprg kbfixlist kbbuglist ---------------------------------------------------------------------- The information in this article applies to: - Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1 - Microsoft FORTRAN for OS/2, versions 5.0 and 5.1 ---------------------------------------------------------------------- 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 reference words: 5.00 5.10 buglist5.00 buglist5.10 fixlist1.00 KBCategory: kbprg kbfixlist kbbuglist KBSubCategory: FORTLngIss

Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: January 25, 1995