StrToFloat com decimais igual a zero
03/01/2006
0
Alguém sabe com fazer para que na hora de converter um valor de uma string igual a 800,00 para float sejam mantidas as decimais 00.
Na hora de fazer a conversão e gravar no banco, somente são mantidas as decimais quando o valor for diferente de zero por exemplo 800,03.
Se o valor for 800,00 será gravado no banco somente 800.
Utilizei a função StrToFloat mas não funcionou. O valor informado faz parte do registro de um arquivo texto que está sendo importado para o banco.
Obrigado
Airton
Airoosp
Posts
03/01/2006
Airoosp
Airton
03/01/2006
Airoosp
É alguma função desenvolvida a parte?
03/01/2006
Edilcimar
03/01/2006
Airoosp
03/01/2006
Edilcimar
Converts a floating point value to a string, using a specified Format, Precision, and Digits.
Unit
SysUtils
Category
Floating point conversion routines
Delphi syntax:
function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string; overload;
function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer; const FormatSettings: TFormatSettings
): string; overload;
C++ syntax:
extern PACKAGE AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format, int Precision, int Digits);
extern PACKAGE AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format, int Precision, int Digits, const TFormatSettings FormatSettings);
Description
FloatToStrF converts the floating-point value given by Value to its string representation.
The Value parameter is the value to convert.
The Precision parameter specifies the precision of the given value. It should be 7 or less for values of type Single, 15 or less for values of type Double, and 18 or less for values of type Extended.
The Digits and Format parameters together control how the value is formatted into a string. For details, see the description of TFloatFormat.
If the given value is a NAN (not-a-number), the resulting string is ´NAN´. If the given value is positive infinity, the resulting string is ´INF´. If the given value is negative infinity, the resulting string is ´-INF´.
The first form of FloatToStrF is not thread-safe, because it uses localization information contained in global variables. The second form of FloatToStrF, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of FloatToStrF, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings.
03/01/2006
Airoosp
03/01/2006
Airoosp
Por exemplo:
variavel string = 800,00 ao converter para float para gravação visto que o campo da tabela é number(15,2) o valor passa para 800. Preciso que grave o valor 800,00 .
03/01/2006
Edilcimar
Clique aqui para fazer login e interagir na Comunidade :)