Truncated value in Floating Point toString() method in the unity editor

Hey everybody,

we are using the GameSparks Unity SDK together with the latest Unity versions and we got a very strange behavior of the unity editor (2018.1.5+ up to latest 2019.1) on windows machines (Windows 10 pro) when using the “toString()” method of float variables.

This problem was not happening with Unity 2017 versions.

Our method has a float input parameter X and passes X.toString() into a GameSparks method SetEventAttribute(“key_string”, X.toString()). This sets the string from X.toString() as a parameter to be sent via an https web request to GameSparks, but the float values get truncated to only one decimal number after the decimal point remains. The input floating values can be any float values passed into the method.

So lets say we pass in 2.123456 , the string value will be just 2.1 .

My assumption is that the unity editor may use some interpreter/compiler simplification or optimization. The interesting thing is that the SetEventAttribute method just needs a “string”, it does not care about what string value is inside.

The problem really happens only in the Unity Editor on Windows, not on macOS and not on mobile devices (both Android and iOS). The problem is not related to IEEE floating point representation of approximated real numbers.

EDIT: First we thought it might be related to a Windows Update. After a fresh Windows 10 Pro installation there was no problem, after the Windows Update the problem occurs. Maybe it is also related to .NET updates.

I appreciate any help / support of this problem, since it heavily effects our development and produces lots of corrupt data on our servers.

Same issue here! Dont know where it comes from.