Tip for "Float value truncated in implicit conversion to integer" Warning

Discuss issues and ideas you have to configuring displays with PowerVision
mbuckman
Posts: 1
Joined: Tue May 16, 2017 9:29 am

Tip for "Float value truncated in implicit conversion to integer" Warning

Post by mbuckman » Fri Jul 21, 2017 9:52 am

Since switching to PV 2.9.20040, I've noticed that some existing configs produce the warning: "Float value truncated in implicit conversion to integer" when compiling scripts. In most cases, this is the result of a float/double value being assigned to an int variable as shown below:

Code: Select all

//Example of Error:
int X;
double Y = 2;
X = Y;
To prevent the warning, the float/double on the right-hand side of the assignment should be enclosed by 'int()'. Preceding it with '(int)' won't work.

Code: Select all

//Example of Solution:
int X;
double Y = 2;
X = int(Y);
This also works for longer expressions.

Code: Select all

//Extended Example:
int X;
double Y = 2;
X = int(Y*2+7);