Hi, i am making some simulation game and my team found strange bug.
The simulation result of unity editor and window published exe is different.
And we found some floating point bug and we make some test code like below.
The result is different also.
I think script engine of unity3d editor have some serious bug about return value processing.
using UnityEngine;
using System.Collections;
public class FloatTest : MonoBehaviour {
string str = "";
float Func()
{
return 0.1f * 0.1f;
}
float Func1(float index)
{
return index * 0.1f;
}
// Use this for initialization
void Start () {
float test = Func();
float value = Func1(0.1f);
if( Func() == Func1(0.1f) )
{
str += "test1 same:";
}
else
{
str += "test1 differ:";
}
if( (float)Func() == (float)Func1(0.1f) )
{
str += "test2 same:";
}
else
{
str += "test2 differ:";
}
double r1 = Func ();
double r2 = Func1 (0.1f);
if( r1 == r2 )
{
str += "test3 same:";
}
else
{
str += "test3 differ:";
}
if(Func().Equals(Func1(0.1f)))
{
str += "Equals is true: ";
}
else
{
str += "Equals is false: ";
}
}
void OnGUI()
{
GUI.Label(new Rect(0, 0, 1000, 100), str);
}
}