Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5841867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:56:41+00:00 2026-05-22T11:56:41+00:00

I just found in the documentation that FloatToStr and DateToStr are not thread-safe in

  • 0

I just found in the documentation that FloatToStr and DateToStr are not thread-safe in their one-paramater overloads. The reason is that they access localization information stored in global variables.

My question is: is this of any practical relevance if I do not change the format settings at runtime? As far as I understand it, I’m on the safe side as long as everyone only reads the format settings – even from multiple threads.

Is that true or am I missing something here?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:56:42+00:00Added an answer on May 22, 2026 at 11:56 am

    FloatToStr, DateToStr and others similar functions are reading global format settings. So, if your application does not change these settings for these function calls, then it is thread safe. The following code on opposite is not thread safe:

    DecimalSeparator := ',';
    try
      s := FloatToStr(123.45);
    finally
      DecimalSeparator := '.';
    end;
    

    When you need the tread safety and “local” format settings, then you have to use overloaded functions, which take as last parameter: AFormatSettings: TFormatSettings. So, to make above code thread safe you have to write:

    var
      fs: TFormatSettings;
    
    GetLocaleFormatSettings(GetThreadLocale, fs);
    fs.DecimalSeparator := ',';
    s := FloatToStr(123.45, fs);
    

    Notes:

    1. GetLocaleFormatSettings and fs initialization may be called once and then fs may be used multiple times. This will speedup the code.
    2. Instead of GetLocaleFormatSettings may be used TFormatSettings.Create. I am not sure when that was introduced, but I see that in Delphi XE.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just found out that the video output of the iPad is not a system
I just found out that every time onclick event for my <button> placed inside
I just found out that the jQueryUI now has it's own built-in auto-complete combo
I just found out that boost::array::static_size isn't part of tr1::array, or at least it's
To my horror I've just found out that chr doesn't work with Unicode, although
I just found web2py a couple days ago, and have been reading the documentation
I've looked around, and not found much documentation on this, so I thought I'd
Update : I just found this documentation page . Wish there was a link
Just found the following in the Java EE Documentation for javax.faces.component.UISelectMany : Obtain the
Just found out about Caliper, and going through the documentation - it looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.