One solution is to use the anytype type to hold the vaue for conversion and then using the any2int function, as shown below:static void Job47(Args _args)
{
real r = 3.13;
int i = r; // Warning is issued here
anytype a;
a = r; // Assign to an anytype variable...
i = any2int(a); // ... and back into an int
print r;
print i;
pause;
}int i = r; // Warning is issued here
anytype a;
a = r; // Assign to an anytype variable...
i = any2int(a); // ... and back into an int
print r;
print i;
pause;
This should be packaged into a function, maybe called int RealToInt(real arg).
Another way would be doing the conversion in managed code (through the System.Convert::ToInt32(object) method), but the performance will not be as good because of the marshalling that needs to take place.
I hope this helps.
No comments:
Post a Comment