title: Why does FloatToStr ignore ThousandSeparator?
body: <p>I am trying to convert a Double and/or Currency to a string for usage in an SQL call.  This means I am always interested in <code>ThousandSeparator</code> being nothing and <code>DecimalSeparator</code> being '.'.</p>
  
  <p>Of course, since my machine's locale is configured to Danish, Windows will return '.' for <code>ThousandSeparator</code> and ',' for <code>DecimalSeparator</code>.  As such I need to compensate for the very likely case of the locale being wrong.</p>
  
  <p>Moreover, my code needs to work in both D2007 (for legacy reasons) and XE3.  As such the code looked like this:</p>
  
  <pre><code>{$IF CompilerVersion&gt;=19}
  fms := TFormatSettings.Create(LOCALE_SYSTEM_DEFAULT);
  {$ELSE}
  GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, fms);
  {$IFEND}
  fms.ThousandSeparator := '?';
  fms.DecimalSeparator := '.';
  Result := FloatToStr(Val, fms);
  Result := StringReplace(Result, '?', '', [rfReplaceAll]);
  </code></pre>
  
  <p>Of course, one could argue that since we presume <code>FloatToStr</code> to only ever make use of <code>TFormatSettings</code>' <code>ThousandSeparator</code> and <code>DecimalSeparator</code> creating it with any locale would be pointless as we are overwriting them anyway.</p>
  
  <p>Still, I thought this was a lot of code for a very simple operation.  I was also not a fan of the <code>ThousandSeparator</code> being '?' and then being removed by <code>StringReplace()</code>.  But since <code>ThousandSeparator</code> is a <code>char</code>, it cannot actually be blank.</p>
  
  <p>I ran some tests on <code>FloatToStr</code> and <code>FloatToStrF</code> to be sure, at which point I noticed that <code>TFormatSettings.ThousandSeparator</code> was completely ignored:</p>
  
  <pre><code>fms := TFormatSettings.Create;
  fms.ThousandSeparator := 'W';
  fms.DecimalSeparator := '.';
  Writeln(FloatToStr(1234567.8901, fms));
  Writeln(FloatToStrF(1234567.8901, ffFixed, 18, 4, fms));
  </code></pre>
  
  <p>I would expect each result to be '1W234W567.8901', but instead it was just '1234567.8901'.  So I wonder if this is expected behaviour or an oddity.</p>
  
  <p>Because even if I cannot avoid <code>TFormatSettings</code>, if I can at least ignore the <code>ThousandSeparator</code>, I suppose I would have saved two lines of code (not that it matters that much, I suppose), but would it be safe to do so?  Can I always expect <code>FloatToStr</code> to ignore the <code>ThousandSeparator</code>?</p>