BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Regional Settings and sprintf?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Robert G. Hoover
Guest





PostPosted: Wed May 16, 2007 10:22 pm    Post subject: Regional Settings and sprintf? Reply with quote



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
Back to top
Bob Gonder
Guest





PostPosted: Wed May 16, 2007 11:34 pm    Post subject: Re: Regional Settings and sprintf? Reply with quote



Robert G. Hoover wrote:

Quote:
However, I'm using String("").sprintf("%.03f", MyFloat) to convert back to a
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?

How about FloatToStrF() ?
Back to top
Robert G. Hoover
Guest





PostPosted: Fri May 18, 2007 2:08 am    Post subject: Re: Regional Settings and sprintf? Reply with quote



Hi Bob,

Excellent! That did the trick. It's amazing how you look through the list of
available functions and miss something that obvious!

I see in the documentation a concern about being threadsafe? That kinda scares
me at this point. I've been fighting with the new dual core architecture for
months now with my programs only to find that I need to patch Windows XP SP2
because Micro$oft's stuff isn't designed to run the dual core machines and even
some of the faster single core machines! LOL

Thanks,

Rob



Bob Gonder wrote:
Quote:
Robert G. Hoover wrote:

However, I'm using String("").sprintf("%.03f", MyFloat) to convert back to a
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?

How about FloatToStrF() ?

Back to top
Alan Bellingham
Guest





PostPosted: Fri May 18, 2007 2:07 pm    Post subject: Re: Regional Settings and sprintf? Reply with quote

"Robert G. Hoover" <not.a.real.address (AT) anywhere (DOT) sorry> wrote:

Quote:
months now with my programs only to find that I need to patch Windows XP SP2
because Micro$oft's stuff isn't designed to run the dual core machines and even
some of the faster single core machines! LOL

Interestingly, I've never had a problem with Windows 2000 on a
multi-processor PC. Which bit of Windows was falling over?!

Alan Bellingham
--
ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK
Back to top
Robert G. Hoover
Guest





PostPosted: Mon May 21, 2007 4:30 pm    Post subject: Re: Dual-core problems - Was: Regional Settings and sprintf Reply with quote

Hi Alan,

I haven't been able to pinpoint the problem yet. I have a dual-core in
in my house that we're using to host data for internet viewing. It has
reset itself many times during operations such as downstreaming audio in
Firefox (internet radio), downstreaming video in Firefox (youtube,
quicktime), and running a screensaver. The screensavers are written (in
BCB2006) to not respond to mouse or keyboard input (except ALT-F4) so my
son isn't able to confuse windows. (He's two years old.)

Of the dual-cores at work, similar problems have occurred where they
reset themselves during operations of my robotics program, written in
BCB2006. So, it's either the OS or it's my programs. I'm trying to
eliminate 1 or the other now.

Our PC supplier (AOpen cubes) sent this link which makes me suspect the
OS. But as much as I love blaming Micro$oft for problems, it could very
well be (and likely is) something that I'm doing in my code.

http://support.microsoft.com/kb/896256/en-us

For the past week, I've been trying to duplicate the symptom and have
been unsuccessful on my home PC which does not run my robotics software.
At work, I have an unfamiliar "blue screen of death".
(http://tritekcorp.com/BlueScreen002.jpg)

So, I don't have much information as of yet. I'm still investigating.
But if anyone has has similar experiences, I'd sure like to hear about
it.... ;)

Many thanks,

Rob



Alan Bellingham wrote:
Quote:
"Robert G. Hoover" <not.a.real.address (AT) anywhere (DOT) sorry> wrote:

months now with my programs only to find that I need to patch Windows XP SP2
because Micro$oft's stuff isn't designed to run the dual core machines and even
some of the faster single core machines! LOL

Interestingly, I've never had a problem with Windows 2000 on a
multi-processor PC. Which bit of Windows was falling over?!

Alan Bellingham
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.