<html>
    <head>
      <base href="http://bugzilla.scilab.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
         <tr>
                <th>Reporter</th>
            <td>stephane.mottelet@utc.fr</td>
         </tr>
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - int8 an iconvert pages are ambiguous about conversion from double"
   href="http://bugzilla.scilab.org/show_bug.cgi?id=15509">15509</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>int8 an iconvert pages are ambiguous about conversion from double
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Scilab software
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0 nightly or development
          </td>
        </tr>


        <tr>
          <th>OS</th>
          <td>All OS
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Minor
          </td>
        </tr>


        <tr>
          <th>Component</th>
          <td>Documentation pages
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>bugzilla.admin@scilab.org
          </td>
        </tr>
</table>
      <p>
        <div>
        <pre>When the value of a double x is greater that the maximum value of integer type and lower than M=2^53, i.e. the greatest integer such that *every*
integer such that n<=M is exactly represented as a double, then the conversion done by int8(x),uint8(x),...,int32(x),uint32(x) is done by a
truncation of fractionnal part followed by a wrapping. If 2^64-1 > x > 2^53, there will be a loss of precision but the behavior is still predictable,
but int64 and uint64 won't be able to do any wrapping because there is a complimentary problem when x>=2^64 :

In this case no value of x can be represented in the largest integer type, i.e. uint64. For example, the result of 

uint64(2^64)

is platform dependent and maybe for Windows even compiler dependent (see <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - uint64() is puzzled over [uint64(%inf)/2 uint64(%inf)]"
   href="show_bug.cgi?id=15506">bug #15506</a>). As explained in

<a href="https://stackoverflow.com/questions/33824954/cast-from-unsigned-long-long-to-double-and-vice-versa-changes-the-value">https://stackoverflow.com/questions/33824954/cast-from-unsigned-long-long-to-double-and-vice-versa-changes-the-value</a>

"A prvalue of a floating point type can be converted to a prvalue of an integer type. The conversion truncates; that  is, the fractional part is
discarded. The behavior is undefined if the truncated value cannot be represented in the destination type. So this code potentially causes undefined
behaviour. When undefined behaviour has occurred, anything can happen, including (but not limited to) bogus output."

Maybe the help page should mention this.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>