Bug 10375 - ToString() method on Double type does not return the same syntax on simulator and real phone
Summary: ToString() method on Double type does not return the same syntax on simulator...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-18 10:37 UTC by Simon CORSIN
Modified: 2013-02-18 11:22 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Simon CORSIN 2013-02-18 10:37:18 UTC
A short code snippet should be self-explanatory:

double number = 42.1337;

Console.WriteLine(number.ToString());

>> 42,1337 < Real device
>> 42.1337 < Simulator


I tried also number.ToString("R"), with the same result. The Microsoft documentation shows that it is supposed to use a "point" and not a comma. My workaround for now is to simply use:

Console.WriteLine(number.ToString().Replace(",", ".");

>> 42.1337 < Real device
>> 42.1337 < Simulator
Comment 1 Sebastien Pouliot 2013-02-18 11:01:51 UTC
That looks like a culture issue. Are you sure your device and simulator have the same language and regional settings ?
Comment 2 Simon CORSIN 2013-02-18 11:19:49 UTC
Indeed! My phone was in English but with the French Region Format. I really did not know it would has an effect on the ToString behaviour. Thanks and sorry for the waste of time.
Comment 3 Sebastien Pouliot 2013-02-18 11:22:04 UTC
Pas de probleme :-)

Console.WriteLine (number.ToString(CultureInfo.InvariantCulture));

^ should always return the same '.' separator whatever the current culture