<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Janne,<br>
    <br>
    <blockquote
      cite="mid:15386475.2013951331792573961.JavaMail.support.mn@elisanet.fi"
      type="cite">
      <blockquote type="cite">
        <pre wrap="">Disabling that option, the result returned in the version of proj 
compiled with Microsoft Visual C++ 2003 is more consistent.
Is there any reason why the /Op option is used to compile the proj?

</pre>
      </blockquote>
      <pre wrap="">
I think that the /Op option only works with the 2003 version and what it does is as follows
(text from MSDN):


"This option improves the consistency of floating-point tests for equality and inequality by disabling optimizations that could change the precision of floating-point calculations.

By default, the compiler uses the coprocessor's 80-bit registers to hold the intermediate results of floating-point calculations. This increases program speed and decreases program size. However, because the calculation involves floating-point data types that are represented in memory by less than 80 bits, carrying the extra bits of precision (80 bits minus the number of bits in a smaller floating-point type) through a lengthy calculation can produce inconsistent results."

<a class="moz-txt-link-freetext" href="http://msdn.microsoft.com/en-us/library/aa984742(v=vs.71).aspx">http://msdn.microsoft.com/en-us/library/aa984742(v=vs.71).aspx</a>


So it is rather obvious that MS compilers use the full 80 bit FPP registers in PC processors by default and in most cases and the reason for using that switch in the first place must be the idea to have similar performance with other ANSI compiler environments? I am not sure if this answered the question?

regards: Janne.

</pre>
    </blockquote>
    <br>
    Ok, the /Op option seems to be used to produce consistent and
    repeatable results.<br>
    The problem is that the cost of tha<em></em>t repeatability is that
    the intermidiate results in computations *lose accuracy*.<br>
    That explains the problem proj (compiled with Visual Studio 2003) is
    having in the conversion I stated before.<br>
    <br>
    <br>
    It is well explained here (text from MSDN) <br>
    <br>
    <a
href="http://msdn.microsoft.com/en-us/library/aa289157%28v=vs.71%29.aspx">http://msdn.microsoft.com/en-us/library/aa289157%28v=vs.71%29.aspx</a><br>
    <br>
    "<span style="color: rgb(0, 0, 0); font-family: 'Segoe
      UI',Verdana,Arial; font-size: 13px; font-style: normal;
      font-variant: normal; font-weight: normal; letter-spacing: normal;
      line-height: normal; orphans: 2; text-align: left; text-indent:
      0px; text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; display: inline ! important; float: none;">Many
      C++ compilers offer a "consistency" floating-point model, (through
      a /Op or /fltconsistency switch) which enables a developer to
      create programs compliant with strict floating-point semantics.
      When engaged, this model prevents the compiler from using most
      optimizations on floating-point computations [...]. The
      consistency model, however, has a dark-side. In order to return
      predictable results on different FPU architectures, nearly all
      implementations of /Op round intermediate expressions to the user
      specified precision; for example, consider the following
      expression:<br>
      <br>
    </span>
    <pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Consolas, Courier, monospace; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: normal; overflow-x: auto; overflow-y: auto; color: rgb(0, 0, 0); font-size: 13px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">float a, b, c, d, e;
. . .
a = b*c + d*e;

<span style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">In order to produce consistent and repeatable results under /Op, this expression gets evaluated as if it were implemented as follows:</span>
</pre>
    <br>
    <pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Consolas, Courier, monospace; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: normal; overflow-x: auto; overflow-y: auto; color: rgb(0, 0, 0); font-size: 13px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">float x = b*c;
float y = d*e;
a = x+y;

<span style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">The final result now suffers from single-precision rounding errors<span class="Apple-converted-space">&nbsp;</span></span><i style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">at each step in evaluating the expression</i><span style="color: rgb(0, 0, 0
 ); font
-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">. Although this interpretation doesn't strictly break any C++ semantics rules, it's almost never the best way to evaluate floating-point expressions. It is generally more desirable to</span><i style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "> compute the intermediate results in as high a
 s precis
ion as is practical</i><span style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">. For instance, it would be better to compute the expression a=b*c+d*e in a higher precision as in,</span>
</pre>
    <pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Consolas, Courier, monospace; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: normal; overflow-x: auto; overflow-y: auto; color: rgb(0, 0, 0); font-size: 13px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">double x = b*c;
double y = d*e;
double z = x+y;
a = (float)z;</pre>
    <br>
    <span style="color: rgb(0, 0, 0); font-family: 'Segoe
      UI',Verdana,Arial; font-size: 13px; font-style: normal;
      font-variant: normal; font-weight: normal; letter-spacing: normal;
      line-height: normal; orphans: 2; text-align: left; text-indent:
      0px; text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; display: inline ! important; float: none;">or
      better yet<br>
      <br>
    </span>
    <pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Consolas, Courier, monospace; word-break: break-all; word-wrap: break-word; font-style: normal; font-weight: normal; overflow-x: auto; overflow-y: auto; color: rgb(0, 0, 0); font-size: 13px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">long double x = b*c;
long double y = d*e
long double z = x+y;
a = (float)z;

</pre>
    <span style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana,
      Arial; font-size: 13px; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: 2; text-align: left; text-indent: 0px; text-transform:
      none; white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
      display: inline !important; float: none; ">When computing the
      intermediate results in a higher precision, the final result is
      *significantly more accurate*. Ironically, by adopting a
      consistency model, the likelihood of error is increased precisely
      when the user is trying to reduce error by disabling unsafe
      optimizations. Thus the consistency model can seriously reduce
      efficiency while simultaneously providing no guarantee of
      increased accuracy. To serious numerical programmers, this doesn't
      seem like a very good tradeoff and is the primary reason that the
      model is not generally well received.</span><br>
    "<br>
    <br>
    From Visual C++ 2005 they are suggesting to use other kind of
    options fp:precise, fp:fast or fp:strict.<br>
    <br>
    <span style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana,
      Arial; font-size: 13px; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: 2; text-align: left; text-indent: 0px; text-transform:
      none; white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
      display: inline !important; float: none; ">"Under<span
        class="Apple-converted-space">&nbsp;</span></span><b style="color:
      rgb(0, 0, 0); font-family: 'Segoe UI', Verdana, Arial; font-size:
      13px; font-style: normal; font-variant: normal; letter-spacing:
      normal; line-height: normal; orphans: 2; text-align: left;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; ">fp:precise</b><span
      style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana,
      Arial; font-size: 13px; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: 2; text-align: left; text-indent: 0px; text-transform:
      none; white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
      display: inline !important; float: none; ">, only safe
      optimizations are performed on floating-point code and, unlike
      /Op, intermediate computations are consistently performed at the
      highest<span class="Apple-converted-space">&nbsp;</span></span><i
      style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana,
      Arial; font-size: 13px; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: normal; orphans: 2;
      text-align: left; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">practical</i><span
      style="color: rgb(0, 0, 0); font-family: 'Segoe UI', Verdana,
      Arial; font-size: 13px; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: 2; text-align: left; text-indent: 0px; text-transform:
      none; white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
      display: inline !important; float: none; "><span
        class="Apple-converted-space">&nbsp;</span>precision.</span>"<br>
    <br>
    Calogero<br>
  </body>
</html>