parseFloat does not work on Windows?

ParseFloat does not seem to work on Windows. It returns 666 for “66.6”. On OSX it returns 66.6. Does anyone have a workaround?

It’s proof… Windows is of the devil. :stuck_out_tongue:

Have you BugReported this problem to UT?

I think it has something to do with language settings. I’m a Dutch speaking Belgian with an English OS.

The result of a ToString in Unity on 66.6 returns “66,6” on that machine. So a comma instead of a period. Which is how this number would be spelled in Dutch, but not in any programming language I know.I’ve never had a problem like this with other programming languages on that machine.

How would I do that?

Go into the Unity folder and open “Report Bug”

It’s not a unity bug… or a bug. Here’s what I use

    static System.Globalization.NumberFormatInfo nfi;
    internal static System.Globalization.NumberFormatInfo numberFormat
    {
        get
        {
            if (nfi == null)
            {
                nfi = new
                    System.Globalization.NumberFormatInfo();
                nfi.NumberDecimalSeparator = ".";
                nfi.NumberGroupSeparator = ",";
            }
            return nfi;
        }
    }
[..]
float fvalue = float.Parse(stringvalue, numberFormat);

http://forum.unity3d.com/viewtopic.php?t=7345 for the issues we hit in Splume serialization.

Thanks for the tip! :!: :smile:
Is there any way to find and use the number format in Javascript?

Hi Matthew!
(Tale of Tales’ Michael Samyn here, of The Path… see you next week in San Francisco! :slight_smile: )

It’s basically the same thing. In Unity, everything uses .NET.

–Eric