Article View: borland.public.cppbuilder.nativeapi
Article #1964Regional Settings and sprintf?
From: Robert G. Hoover
Date: Wed, 16 May 2007 17:22
Date: Wed, 16 May 2007 17:22
17 lines
1748 bytes
1748 bytes
Hi All,
If I use AnsiString::ToDouble(), then this will convert a floating point number
string to a 'float' as per my Regional Settings. For example, if an American
user inputs "5.2" I get 5.2 and if a European user inputs "5,2" I get 5.2. No
problem here.
However, I'm using String("").sprintf("%.03f", MyFloat) to convert back to a
string for output. I get "5.200" independent of Regional Settings. I assume this
is because the sprintf doesn't take these global settings into account. If I use
StrToFloat, I end up with something like "5.200000384". I am using sprintf so I
can limit the number of significant digits displayed. Is there a way to limit my
sigdigs and utilize the global Regional Settings of Windows?
Many thanks,
Rob
Technical Details
Message-ID:
<464b3dc6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3b64aa92b9a80666,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 16 May 2007 13:22:16 -0400 From: "Robert G. Hoover" <not.a.real.address@anywhere.sorry> User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Regional Settings and sprintf? X-Enigmail-Version: 0.94.1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 000740-2, 05/16/2007), Outbound message X-Antivirus-Status: Not-Tested NNTP-Posting-Host: 76.106.54.160 Message-ID: <464b3dc6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1179336134 76.106.54.160 (16 May 2007 10:22:14 -0700) Lines: 17 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail