티스토리 뷰

Delphi

function TextToFloat(Buffer: PWideChar; var Value; ValueType: TFloatValue): Boolean;

function TextToFloat(Buffer: PWideChar; var Value; ValueType: TFloatValue; const AFormatSettings: TFormatSettings): Boolean;

function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue): Boolean;

function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue; const AFormatSettings: TFormatSettings): Boolean;

C++

extern PACKAGE bool __fastcall TextToFloat(System::WideChar * Buffer, void *Value, TFloatValue ValueType)/* overload */;

Properties

Type

Visibility

Source

Unit

Parent

function

public

System.SysUtils.pas

System.SysUtils.hpp

System.SysUtils

System.SysUtils

Description

Converts a null-terminated string to a floating-point value.

Use TextToFloat to convert a null-terminated string, Buffer, to a floating-point value.

The string must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa.

The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number.

Leading and trailing blanks are ignored.

The converted value is assigned to the Value parameter, which must be of type Extended or Currency, as indicated by the ValueType parameter.

TextToFloat returns True if the conversion is successful, or False if the Buffer does not contain a valid floating-point value.

null로 끝나는 문자열을 부동 소수점 값으로 변환합니다.

TextToFloat을 사용하여 null로 끝나는 문자열인 Buffer를 부동 소수점 값으로 변환합니다.

문자열은 선택적 기호 (+ 또는 -), 선택적 소수점이 있는 숫자 문자열 및 선택적 가수로 구성되어야 합니다.

가수는 'E' 또는 'e' 다음에 선택적 기호 (+ 또는 -)와 정수로 구성됩니다.

선행 및 후행 공백은 무시됩니다.

변환된 값은 ValueType 매개변수에 표시된 대로 Extended 또는 Currency 유형이어야 하는 Value 매개변수에 할당됩니다.

TextToFloat는 변환이 성공하면 True를 반환하고 버퍼에 유효한 부동 소수점 값이 포함되어 있지 않으면 False를 반환합니다.

 

The first form of TextToFloat is not thread-safe, because it uses localization information contained in global variables.

The second form of TextToFloat, which is thread-safe, refers to localization information contained in the AFormatSettings parameter.

Before calling the thread-safe form of TextToFloat, you must populate AFormatSettings with localization information.

To populate AFormatSettings with a set of default locale values, call TFormatSettings.Create.

TextToFloat의 첫 번째 형식은 전역 변수에 포함된 지역화 정보를 사용하므로 스레드로부터 안전하지 않습니다.

스레드로부터 안전한 두 번째 형식의 TextToFloatAFormatSettings 매개변수에 포함된 지역화 정보를 참조합니다.

스레드로부터 안전한 TextToFloat 양식을 호출하기 전에 AFormatSettings 에 지역화 정보를 채워야 합니다.

AFormatSettings 에 기본 로캘 값을 채우려면 TFormatSettings.Create를 호출합니다.

 

Example

var

  FloatStr: string;

  AnsiCha: PAnsiChar;

  Ext: Extended;

begin

  FloatStr := '테스트3.14';

  AnsiCha := Addr(FloatStr[1]);

 

  // 결과: FALSE

  Writeln(TextToFloat(AnsiCha, Ext, fvExtended));

 

  // 결과: 0.00000000000000E+0000

  Writeln(Ext);

 

 

  FloatStr := '3.141592';

  AnsiCha := Addr(FloatStr[1]);

 

  // 결과: TRUE

  Writeln(TextToFloat(AnsiCha, Ext, fvExtended));

 

  // 결과: 3.00000000000000E+0000

  Writeln(Ext);

  Readln;

end.

 

mantissa 미국·영국 [mæntísə

가수(假數), 고정 소수점 부분

consist 미국식   영국식   중요

1. (부분·요소로) 되어 있다(be made up) ((of))
2. (
…에) 있다(lie), (…에) 존재하다 ((in))
3. (
…와) 양립하다 ((with, together))

whole number 미국식   영국식   

정수, 범자연수

indicated 영국식   

계기에 표시된; 바람직한.

indicate 미국·영국 [|ɪndɪkeɪt]   영국식   중요

1. (사실임・존재함을) 나타내다
2. (
조짐・가능성을) 나타내다
3. (
특히 간접적으로) 내비치다

 

출처: http://docwiki.embarcadero.com/Libraries/XE2/en/System.SysUtils.TextToFloat

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함