Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.fortran    |    Putting John Backus on a giant pedestal    |    5,127 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,547 of 5,127    |
|    Steve Lionel to Woozy Song    |
|    Re: what is point of X=1.0D0*X+1.0D0*Y*W    |
|    23 Nov 23 10:28:40    |
      From: steve@seesignature.invalid              On 11/23/2023 5:29 AM, Woozy Song wrote:       > Where X and Y are both real, and W is double precision. I presume they       > wanted extra precision for the arithmetic, but then it gets quantised       > back to 32-bit float.       > By the way, this code came from a large oil company with a team of       > programmers.              The multiplication by 1.0D0 of each term has no effect whatsoever. If       those were removed, the multiplication of Y*W would convert Y to double,       due to "mixed-mode arithmetic" rules, before doing the operation. Then       when X is added, it too would be converted to double before the       addition. Then the whole result would be rounded back to single       precision for the assignment.              If I were writing this, I'd use the standard conversion intrinsic       functions to make it clear what is happening, as I hate seeing implicit       conversion. For example:              X = REAL(DBLE(X)+(DBLE(Y)*W))              --       Steve Lionel       ISO/IEC JTC1/SC22/WG5 (Fortran) Convenor       Retired Intel Fortran developer/support       Email: firstname at firstnamelastname dot com       Twitter: @DoctorFortran       LinkedIn: https://www.linkedin.com/in/stevelionel       Blog: https://stevelionel.com/drfortran       WG5: https://wg5-fortran.org              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca