Your compiler, you mean. The IDE has nothing to do with whether code compiles or not; it's just the fancy interface.
Are you referring to me? You get an error if you attempt to assign a float to an int? Right, so do I.If you want to assign a floating-point number to an integer, you can use a cast:
That truncuates the value, however; it doesn't round it. To round the value, add .5 first:Code:int x = (int)(3.14159);
Code:int x = (int)(3.14159 + .5);



LinkBack URL
About LinkBacks
If you want to assign a floating-point number to an integer, you can use a cast:



