From 6ff05a44b01c6ac6e33db2ec28dcf6e2a7c2abb0 Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期二, 16 一月 2024 19:46:01 +0800 Subject: [PATCH] fix LDS to Prog --- MTerm1/MTerm1.cpp | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/MTerm1/MTerm1.cpp b/MTerm1/MTerm1.cpp index caad9c8..e8548a5 100644 --- a/MTerm1/MTerm1.cpp +++ b/MTerm1/MTerm1.cpp @@ -576,7 +576,7 @@ return res; } -CString & intToString(int num, int digit) +CString intToString(int num, int digit) { static CString Str1; if (digit != 0) { @@ -598,7 +598,29 @@ return Str1; } +CString fixToString(int num, int digit, int fracdigit) +{ + static CString Str1; + if (digit != 0) { + CString str2; + str2.Format(_T("%%%dd"), digit); + Str1.Format(str2, num); + } + else { + Str1.Format(_T("%d"), num); + } + + int k = Str1.GetLength(); + int j = (k - 1 - fracdigit) / 3; //閫楀彿涓暟 + int l = k - fracdigit - j * 3; //璧峰浣嶇疆 + for (int i = l; i < k -fracdigit + j; i += 4) + { + Str1.Insert(i, _T(",")); + } + if (fracdigit>0) Str1.Insert(k - fracdigit + j, '.'); + return Str1; +} CString & intToBinString(int num, int digits) { static CString Str1; -- Gitblit v1.9.1