Interger (int) value in GlobalVariableSet()

 

I want to assign an integer (int) value to a GlobalVariable. Can an integer (int) value be modified to double value before assigned to GlobalVariableSet(), to avoid getting the data conversion warning with GlobalVariableGet() ?? If yes, How?

 
wackena posted  :

I want to assign an integer (int) value to a GlobalVariable. Can an integer (int) value be modified to double value before assigned to GlobalVariableSet(), to avoid getting the data conversion warning with GlobalVariableGet() ?? If yes, How?

 

Assigning to a Global Variable is fine - I don't think converting up from int to double will give a conversion error because there's no potential loss of data.  To be absolutely safe about getting the correct int back, I would use MathRound (which also returns a double, something I don't understand), and also explictly typecast to int to avoid the warning.

int nGlobal=(int)MathRound(GlobalVariableGet("Global Integer"));
 
phampton :

Assigning to a Global Variable is fine - I don't think converting up from int to double will give a conversion error because there's no potential loss of data.  To be absolutely safe about getting the correct int back, I would use MathRound (which also returns a double, something I don't understand), and also explictly typecast to int to avoid the warning.

Thanks very much.