{"id":4319,"date":"2014-03-30T09:51:24","date_gmt":"2014-03-30T09:51:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/thread-safeness-of-floattostr-datetostr-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:51:24","modified_gmt":"2014-03-30T09:51:24","slug":"thread-safeness-of-floattostr-datetostr-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/thread-safeness-of-floattostr-datetostr-collection-of-common-programming-errors\/","title":{"rendered":"Thread-Safeness of FloatToStr \/ DateToStr-Collection of common programming errors"},"content":{"rendered":"<p>Even the global settings can change when Application.UpdateFormatSettings (Delphi 7, don&#8217;t know about Delphi XE) is True. When a user changes the Regional and Language options of Windows, this will be reflected in your application. You can circumvent this by setting UpdateFormatSettings to False, but even then you can&#8217;t be sure, maybe there is some third party library you use that changes it.<\/p>\n<p>I had some problems with our own application: Nowhere in our application the global formatsettings were changed, but still there was information loss because a float was converted to a string and when the string was converted back to float, the formatsettings were magically changed. (So you had this: 1.2 -&gt; convert to string -&gt; &#8216;1.2&#8217; -&gt; black magic that changed formatsettings.decimalseparator -&gt; convert to float -&gt; 12).<\/p>\n<p>My suggestion: only use the not thread-safe version for UI purposes so the user sees dates and floats the way he likes them to see, for everything else, use the thread-safe version. Conversions inside your application will then be consistent and don&#8217;t give surprises.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Even the global settings can change when Application.UpdateFormatSettings (Delphi 7, don&#8217;t know about Delphi XE) is True. When a user changes the Regional and Language options of Windows, this will be reflected in your application. You can circumvent this by setting UpdateFormatSettings to False, but even then you can&#8217;t be sure, maybe there is some [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4319","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4319"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4319\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}