Subject | Re: [ib-support] to change the decimal separator |
---|---|
Author | aandea_launch |
Post date | 2006-08-30T05:16:22Z |
Hello Alexandre ,
The danger in using this function :
function FloatToStrSQL(D:Extended):String;
var
wDecimalSeparator:Char;
begin
wDecimalSeparator := DecimalSeparator;
DecimalSeparator := '.'
try
Result := FloatToStr(D);
finally
DecimalSeparator := wDecimalSeparator;
end;
end;
is in multi-threaded envrionments, where one thread might set the
separator back before you are doing the conversion in other thread...
--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
<iblist@...> wrote:
The danger in using this function :
function FloatToStrSQL(D:Extended):String;
var
wDecimalSeparator:Char;
begin
wDecimalSeparator := DecimalSeparator;
DecimalSeparator := '.'
try
Result := FloatToStr(D);
finally
DecimalSeparator := wDecimalSeparator;
end;
end;
is in multi-threaded envrionments, where one thread might set the
separator back before you are doing the conversion in other thread...
--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
<iblist@...> wrote:
>me.
> Robert martin wrote:
> > Hi
> >
> > I have never used the code you have here but it looks dangerous to
> > Why not just use the following (if you are going to hard code theDelphi
> > decimal separator).
> >
> > Result := FormatFloat('##0.00', D);
> >
> >
> > Rob Martin
> > Software Engineer
> >
>
> Why dangerous ?
>
> Because if i dont specify that the DecimalSeparator should be "."
> uses the Windows Locale Seetings, that in Brazil is defined to useComma
> as Decimal Separator, so the result ofan example)
>
> FormatFloat('##0.00', 123.45)
>
> will be 123,45 that is the exactly problem that started this thread.
>
> Off course parameters are preferred.
>
> but in the function e wrote (without exception handling and just as
> the result will be
> 123.45 no matter how DecimalSeparator as set on Windows Locale Settings.
>
> see you !
>
>
> --
> Alexandre Benson Smith
> Development
> THOR Software e Comercial Ltda
> Santo Andre - Sao Paulo - Brazil
> www.thorsoftware.com.br
>