There is a mistake in the example script that derives the numeric limits for "safe" typecasting long -> double without losing precision.
When converting long/ulong type into double, precision may be lost in case the integer value is greater than 9223372036854774784 or less than -9223372036854774784.
The correct statement should be:
When converting long/ulong type into double, precision may be lost in case the integer value is greater than9007199254740992or less than-9007199254740992, i.e., [-2^53, 2^53].
Corrected version of the script:
voidOnStart()
{
long l_max=LONG_MAX; // 2^63 -1 (9223372036854775807)long l_min=LONG_MIN; // -2^63 (-9223372036854775808)//--- define the highest integer value, which does not lose accuracy when being cast to doublewhile(l_max!=long((double)l_max))
l_max/=2;
//--- define the lowest integer value, which does not lose accuracy when being cast to doublewhile(l_min+1!=long((double)(l_min+1)))
l_min/=2;
//--- include the upper boundary in the found interval
l_max++;
//--- derive the found interval for integer valuesPrintFormat("When casting an integer value to double, it must be ""within [%I64d, %I64d] interval",l_min,l_max);
//--- now, let's see what happens if the value falls out of this intervalPrintFormat("l_max+1=%I64d, double(l_max+1)=%.f, long(double(l_max+1))=%I64d",
l_max+1,double(l_max+1),long(double(l_max+1)));
PrintFormat("l_min-1=%I64d, double(l_min-1)=%.f, long(double(l_min-1))=%I64d",
l_min-1,double(l_min-1),long(double(l_min-1)));
//--- receive the following result// When casting an integer value to double, it must be within [-9007199254740992, 9007199254740992] interval// l_max+1=9007199254740993, double(l_max+1)=9007199254740992, long(double(l_max+1))=9007199254740992// l_min-1=-9007199254740993, double(l_min-1)=-9007199254740992, long(double(l_min-1))=-9007199254740992
}
References for the "max safe integer" for typecasting long -> double:
Fixed, thank you
there is more: same error
... levels!=ArraySize(widths) || levels!=ArraySize(widths))error1
error2
error3
error4
error5
<Post edited and fixed by moderator>
there is more: same error
error1
error2
error3
error4
error5
<Post edited and fixed by moderator>
Thank you. This will not cause an error, so it will be fixed sometime later.
In the opencl example you have an error in the cl code i think :
should be
its here :
https://www.mql5.com/en/docs/opencl/clprogramcreate
cheers
CL_DEVICE_MAX_WORK_GROUP_SIZE
From Khronos : Maximum number of work-items in a work-group executing a kernel
Your docs : The total number of the local working groups
https://www.mql5.com/en/docs/opencl/clgetinfointeger
On the documentation page https://www.mql5.com/en/docs/basis/types/casting
Typecasting
There is a mistake in the example script that derives the numeric limits for "safe" typecasting long -> double without losing precision.
When converting long/ulong type into double, precision may be lost in case the integer value is greater than 9223372036854774784 or less than -9223372036854774784.
The correct statement should be:
When converting long/ulong type into double, precision may be lost in case the integer value is greater than 9007199254740992 or less than -9007199254740992, i.e., [-2^53, 2^53].
Corrected version of the script:
References for the "max safe integer" for typecasting long -> double:
https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Precision_limitations_on_integer_values
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
https://www.tutorialspoint.com/what-is-javascript-s-highest-integer-value-that-a-number-can-go-to-without-losing-precision
https://stackoverflow.com/questions/1848700/biggest-integer-that-can-be-stored-in-a-double
https://stackoverflow.com/questions/38602078/how-to-get-the-maximum-safest-integer-of-a-double-in-java
https://stackoverflow.com/questions/26380364/why-is-number-max-safe-integer-9-007-199-254-740-991-and-not-9-007-199-254-740-9
I don't think it's explained clearly anywhere in the documentation that an array declared with [] but initialized is actually static.
Forum on trading, automated trading systems and testing trading strategies
Why doesn't my ArrayResize resize my 2D Array?
Alain Verleyen, 2023.04.28 13:52
Yes you are right, I missed the point that the array is static because it's initialized (and that is not clear in the documentation).
So if you want a dynamic array and initialize it, you need 2 arrays and copy the values.
Output:
Forum on trading, automated trading systems and testing trading strategies
EnumToString and turning values to string in a template class
Lorentzos Roussos, 2023.01.13 12:24
[concerning the enumapper - the original issue is solved]
There are some undocumented enumerations among the misscounts of course
for instance in ENUM_ACTIVATION_FUNCTION there is no AF_PRELU in the docs
Forum on trading, automated trading systems and testing trading strategies
EnumToString and turning values to string in a template class
Lorentzos Roussos, 2023.01.13 12:40
or the ENUM_DATATYPE
Forum on trading, automated trading systems and testing trading strategies
EnumToString and turning values to string in a template class
Lorentzos Roussos, 2023.01.13 12:48
or ENUM_TERMINAL_INFO_STRING
All errors have been found in offline documentation.
Links to online docs are provided, mostly showing same faults.