﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3817	Double to Int64 type conversion - wrong results	AspirinJunkie	Jon	"Following script:

{{{
$fN = 562949953421312.0
$iN = Int($fN, 2)
$iN2 = Number($iN, 2)

ConsoleWrite(""$fN :"" & $fN & "" ("" & VarGetType($fN) & "")"" & @CRLF & _
	""$iN :"" & $iN & "" ("" & VarGetType($iN) & "")"" & @CRLF & _
	""$iN2:"" & $iN2 & "" ("" & VarGetType($iN2) & "")"" & @CRLF)
}}}
produces:
   $fN :562949953421312 (Double)
   $iN :562949953421313 (Int64)
   $iN2:562949953421313 (Int64)

This applies to all integer numbers >= 2^49^ stored as double.

The numbers themselves can be mapped completely and without rounding errors in IEEE 754 double precision.

The naive approach to implementing an `Int()` function would be a C-type cast (`(long long) fValue)`) or a C++-typecast (`static_cast<long long>(fValue)`).
However, these do not exhibit the problem:
{{{
#include <iostream>

using namespace std;

int main()
{
    double f = 562949953421312.0;
    long long iInt1 = (long long)f;
    long long iInt2 = static_cast<long long>(f);
    
    cout<<iInt1<<""\n""<<iInt2;
}
}}}
In old public source codes of AutoIt also the C-cast was used for the `Int()` function (`(__int64)m_fValue` in method `n64Value` in file `variant_datatype.cpp`).
In the meantime, however, there has apparently been a change here.

"	Bug	closed	3.3.16.1	AutoIt	3.3.15.3	None	Fixed	Int Number	
