If you store a long as a GlobalVariable() and retrieve it back again by casting the double to a long, the returned value is different:
Code: Select all
void OnStart() {
//---
long thisChartID = ChartID();
long newChartID;
GlobalVariableSet("myChartID", thisChartID);
newChartID = (long)GlobalVariableGet("myChartID");
if ( thisChartID != newChartID ) {
PrintFormat("thisChartID = %I64d, newChartID = %I64d", thisChartID, newChartID);
}
}Code: Select all
void OnStart() {
//---
long thisChartID = ChartID();
// Split the long into two ints -- the low 32-bit and the high 32-bit
int l32 = (int)(thisChartID & UINT_MAX);
int h32 = (int)(thisChartID >> 32);
GlobalVariableSet("myChartID_l32", (int)l32);
GlobalVariableSet("myChartID_h32", (int)h32);
int newl32 = (int)GlobalVariableGet("myChartID_l32");
int newh32 = (int)GlobalVariableGet("myChartID_h32");
long newChartID = (long)newh32;
newChartID = newChartID << 32;
newChartID = newChartID | newl32;
PrintFormat("thisChartID = %I64d, newChartID = %I64d", thisChartID, newChartID);
}