Followers 0

# Implicit conversion of value is not exact

## 3 posts in this topic

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
Edited by FDsagizi
0

##### Share on other sites

That is odd. I'll look into this.

Which version of AS are you currently using?

0

##### Share on other sites

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.

Edited by Andreas Jonsson
0

##### Share on other sites

Ok! I'll look into this.

0

## Create an account

Register a new account