| |

VerySource

 Forgot password?
 Register
Search
Author: 血色占卜师

How does CString.Format control the number of bits?

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-22 19:45:01
| Show all posts
"% m.nf", represented by at least m digits, the number of decimal places occupies n digits (fixed n digits, less than 0),
% 5.2f, limited to only 2 digits after the decimal point, and at least 3 digits before the decimal point, if it exceeds 3, normal digits are displayed
float f = 1234.456;
CString str;
str.Format ("% 5.2f", f);
Result: 1234.45
str.Format ("% 3.2f", f);
Result: 1234.45
str.Format ("% 5.1f", f);
Results: 1234.4
Reply

Use magic Report

5

Threads

23

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-1-25 11:45:01
| Show all posts
% 5.2f, limited to only 2 digits after the decimal point, at least 2 digits before the decimal point (the decimal point should occupy one digit), if it exceeds 3, it displays normal digits, and if it is less than three digits, it starts with Spaces
I tried n times and came to this conclusion
Reply

Use magic Report

5

Threads

23

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-1-25 12:00:02
| Show all posts
% 5.2f, limited to only 2 digits after the decimal point, at least 2 digits before the decimal point (the decimal point must occupy one digit), if it exceeds 2, it displays the normal digits, and if it is less than 2 digits, the Spaces
I tried n times and came to this conclusion
Reply

Use magic Report

2

Threads

20

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-25 13:00:02
| Show all posts
This is similar to printf and scanf.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list