Int64ToString

Go to Home Page

Converts a number to a string with optional formatting such as thousands separators and negative signs.

Syntax

int WINAPI Int64ToString (
    INT64 number,
    LPWSTR pwszBuf,
    UINT bufLen,
    BOOL useNumberFormat,
    NUMBERFMT* pFormatInfo,
    DWORD dwFlags
)

Parameters

number
The number to format
pwszBuf
A pointer to the converted string
bufLen
The size of pwszBuf in WCHARs
useNumberFormat
A flag specifying whether to format the number
pFormatInfo
Structure describing the formatting to apply to the number
dwFlags
Bit flag specifying which members of pFormatInfo to use

Return Value

Number of WCHARs written to pszBuf, not including the terminating nul

Remarks

The NUMBERFMT structure is defined in the SDK.

The valid values for dwFlags are:

#define FMT_USE_NUMDIGITS 0x1
#define FMT_USE_LEADZERO  0x2
#define FMT_USE_GROUPING  0x4
#define FMT_USE_DECIMAL   0x8
#define FMT_USE_THOUSAND  0x10
#define FMT_USE_NEGNUMBER 0x20

If useNumberFormat is FALSE, the function converts number to a string and returns. Otherwise, if pFormatInfo is not NULL, the function applies the formatting in pFormatInfo according to which flags are present (i.e. pFormatInfo->NumDigits will only be used if the FMT_USE_NUMDIGITS flag is set). For those flags which aren't set, the corresponding formatting comes from GetLocaleInfo.

If pFormatInfo is NULL, the function behaves as if dwFlags was 0 and all formatting information comes from GetLocaleInfo.

Note, due to a bug in the function, if pFormatInfo is NULL, useNumberFormat is nonzero, and the digit grouping in the user's locale setting is anything other than "123,456,789" in control panel (that's GetLocaleInfo(LOCALE_SGROUPING) returning a string other than '3;0'), then the grouping will not be properly applied, with only the digit before the semi-colon being taken into account.

This function is also known as _Int64ToString@28.