Implicit conversion of value is not exact

Started by
2 comments, last by FDsagizi 10 years, 6 months ago

Hi. some times i have problem with float

AS work strange with this.

example, that code not work because he not understand '0', he think is a "int".


float ret = true ? 0 : 0.1; 

and ok, that code make warning!

next code, work wrong


float f = 0.1;
float ret = 0.2;
ret += false ? 0 : f * 15 ; // ( 15 * 0.1 == 1.5 ) then 1.5 + 0.2 == 1.7 ok ?
output( "ret: " + ret ); // BUT result == 1.2
Advertisement

That is odd. I'll look into this.

Which version of AS are you currently using?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

It was a bug that the compiler didn't implicitly convert the constant 0 to the type in the last expression.

I've fixed that bug in revision 1736. I also took the time to add a compiler warning about a truncated value when a float or double type is implicitly converted to an integer type.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Ok!smile.png I'll look into this.

This topic is closed to new replies.

Advertisement