String.ToDouble in iOS doesn't use Locale.current

When I try to create a double value from a string I got only an integer value when the separator is a comma.

Var xValue As Double

xValue = tfText.Text.ToDouble
system.DebugLog “Value=” + xValue.ToString

tfDouble.Text = xValue.ToString(Locale.Current, “0.0”)

Console log:

If I do this on macOS everything is okay.

Console log:

Did you check your locales are identical? Simulator might have a standard locale.

Yes, everything is set to German.

Testing on iPad Pro M4 iOS 26.1.0

Same problem like in simulator.

Tested on iPhone SE, iOS 15.8.5, the same problem.

Oh yes, missed that point on first reading. You are reading the double value without locale initially, so no wonder it’s not taken into respect. Try

Var xValue As Double

xValue = Double.FromString(fText.Text, locale.current)
system.DebugLog “Value=” + xValue.ToString

tfDouble.Text = xValue.ToString(Locale.Current, "0.0")

(Edited for correct code)

Thanks for this hint. Now it works fine.

1 Like