-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStdAfx.cpp
44 lines (40 loc) · 980 Bytes
/
StdAfx.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
// stdafx.cpp : source file that includes just the standard includes
// FLCompanion.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#define FMTNUM_USE_CENT 1
void FormatNumber(TCHAR* buffer, double value, UINT flags)
{
_stprintf(buffer, _T("$%.2f"), value);
size_t len = _tcslen(buffer);
LPTSTR scan = buffer+len-1;
len = (len-5)*4/3;
LPTSTR scan2 = buffer+5+len;
*scan2-- = '\0';
*scan2-- = *scan--;
*scan2-- = *scan--;
*scan2-- = *scan--;
len = 1;
while (scan >= buffer+2)
{
*scan2-- = *scan--;
if ((++len & 3) == 0)
len++, *scan2-- = ',';
}
}
void FormatNumber(TCHAR* buffer, long value, UINT flags)
{
_stprintf(buffer, _T("$%d"), value);
size_t len = _tcslen(buffer);
LPTSTR scan = buffer+len-1;
len = (len-2)*4/3;
LPTSTR scan2 = buffer+2+len;
*scan2-- = '\0';
len = 1;
while (scan >= buffer+2)
{
*scan2-- = *scan--;
if ((++len & 3) == 0)
len++, *scan2-- = ',';
}
}