[Mono-dev] Simple floating maths problem

Andreas Nahr ClassDevelopment at A-SoftTech.com
Fri Apr 30 06:15:20 EDT 2010


I just tried your sample and if you are looking for a quick workaround (for
yourself, not mono) remove the explicit int cast:

            int fact = 50000;
            float[] tList = { 0.95864f, 0.89374f, 0.89092f, 0.89716f,
0.4191f, 0.79782f };

            foreach (float val in tList)
            {
                float comp = val * fact;
                Console.WriteLine("{0:g} * {1:d} = {2}", val, fact, comp);
            }

BTW: If you are looking for something with high precision then float is no
good choice. .Net/Mono has a Decimal type that offers high precision with
acceptable performance.



More information about the Mono-devel-list mailing list