The Format parameter is a format string used to format the value in Args. What is Args? It is an array of variables, that is, it can have multiple parameters, and each parameter can be different.
For example:
1, format ('My name is %6s', ['Wind']); When I came back, I was: My name is Feng.
Where %6s is a format instruction character.
The decimal number of 2, d represents an integer value. U is an integer value like D, but it is unsigned. If its corresponding value is negative, it will be a number of 2 to the 32nd power minus this absolute value.
Such as: format ('This is% u', [-2]); What is returned is: This is 4294967294.
3, e scientific representation, corresponding to integer and floating point number,
For example: Format ('This is %e', [-2.22]); What is returned is: this is--2.22000000000000E+000.
4, g this can only correspond to floating-point type, it will remove redundant digits from the value.
For example: Format ('This is %g', [02.200]); What is returned is: This is 2.2.
5.n can only correspond to floating-point type, and the value is converted into digital form. Just look at an example.
For example: format ('This is% n', [4552.438+076]); This is 4552.22 return.
6. Format ('This is %m', [9552.21]); Return: This is 9552.438+0.
7. Format ('this is% 1:d %0:d', [12,13]); Return: This is 13 12.
8. Format ('This is %4d', [12]); The output is: This is 12.
9. The specified parameter ["-"] is aligned to the left, and it works best when combined with [width]:
For example: format ('This is %-4d, yes', [12]); The output is: this is 12, that's right.
10 and [". "prec] specify the best precision of floating-point numbers:
Format ('This is %.2f', ['1.1234]); Output this is 1. 12.
Format ('This is %.7f', ['1.1234]); Losing this is 1. 124000.
1 1, and for integers, if the number of digits of prec such as integer is very small, it has no effect, otherwise, it will be preceded by 0.
For example: format ('this is% .7d', [1234]); The output is: this is 000 1234]
12. For character type, it is just the opposite of integer value. If the length of prec is greater than the length of string type, it has no effect; Otherwise, it will truncate the characters at the end.
For example: format ('This is% .2s', ['1234']); The output is 12.
13, format ('this is %e', [-2.22]); What is returned is: this is--2.22000000000000E+000.
How to get rid of extra zeros? This will do.
Format ('This is %.2e', [-2.22]);
Format date time:
Function FormatDateTime (constant format: stringdadatetime: tdatetime): string;
Overload;
Of course, there is another one like Format, but this is only the first one commonly used.
The Format parameter is a formatted string. Date time is a type of time. The return value is formatted.
character string
Pay attention to instruction characters in format parameters.
C displays the time in short time format, that is, all numbers.
FormatdateTime('c ',now);
The output is: August 7, 2004 at 9: 55: 40.
D corresponds to the date in time. If the date is a single digit, one digit is displayed and two digits are displayed.
FormatdateTime('d ',now);
The output may be 1 ~ 3 1
Dd has the same meaning as D, but it is always displayed in two digits.
FormatdateTime('dd ',now);
The output may be 0 1 ~ 3 1.
What day does ddd show?
FormatdateTime('ddd ',now);
The output is: Saturday
Dddd and ddd display the same.
But the above two may be different if they are in other countries.
Ddddd displays the year, month and day in a short time format.
FormatdateTime('ddddd ',now);
The output is: August 7, 2004
Dddddd displays the year, month and day in a long time format.
FormatdateTime('dddddd ',now);
The output is August 7, 2004.
E/ee/eee/eeee displays the year with corresponding numbers.
FormatdateTime('ee ',now);
The output is: 04 (indicating 04).
M/mm/mmm/mmmm represents the month.
FormatdateTime('m ',now);
The output is: 8
FormatdateTime('mm ',now);
The output is 08.
FormatdateTime('mmm ',now);
The output is in August.
FormatdateTime('mmmm ',now);
The output is in August.
Like ddd/dddd, it may be different in other countries.
Yy/yyyy represents the year.
FormatdateTime('yy ',now);
The output is 04.
FormatdateTime('yyyy ',now);
The output was in 2004.
H/hh, n/nn, s/ss and z/zzz represent hours, minutes, seconds and milliseconds respectively.
T display the time in short time format.
FormatdateTime('t ',now);
The output is 10: 17.
Tt displays the time in a long time format.
Format datetime ("TT", now);
The output is 10: 18:46.
Ampm displays morning or afternoon in a long time format.
FormatdateTime('ttampm ',now);
The output is: 10:22:57 am.
Maybe so. If you want to add ordinary strings to the format, you can separate them with double quotation marks.
Specially defined characters, so that ordinary strings with special characters will not be displayed as
Time format:
FormatdateTime ("today" is "c", now);
The output is: today is August 7, 200410: 26: 58.
You can also add "-"or ""to a separate date:
FormatdateTime ("Today is yy-mm-dd", now);
FormatdateTime ("today" is "yy\mm\dd", now);
The output is: today is 04-08-07
You can also use ":"to separate time.
FormatdateTime ("Today is" hh:nn:ss', now);
The output is: Today is 10:32:23.
Format floating point
Commonly used statements:
Function FormatFloat(const format: stringValue: Extended): string; Overload;
As mentioned above, the format parameter is a formatting instruction character and the value is an extended type.
Why this type? Because it has the largest representation range among all floating-point values. If the parameters of this method are passed in.
Such as Double or others, can be saved within the scope.
The key is to look at the usage of format parameters.
0 This instruction specifies the corresponding number of digits.
For example: FormatFloat('000.000', 22.22);
The output is 022.220.
Note that if the number of zeros in the integer part is less than the number of integers in the Value parameter, it has no effect.
Such as: FormatFloat('0.00', 22.22);
The output is: 22.22
However, if the decimal part of 0 is less than a multiple of the decimal in the value, the corresponding decimal and number will be truncated.
Such as: FormatFloat('0.0', 22.22);
The output is: 22.2
You can also specify a comma in the integer 0, and the integer must be greater than 3, so there will be a comma in the sentence.
FormatFloat('0,000.0 ',2222.22);
The output is: 2222.2
If yes, FormatFloat('000, 0.0', 2222.22);
Its output is still: 2222.2.
Pay attention to its regularity.
FormatFloat('##。 ##',22.22);
The output is: 22.00
E scientific representation, look at a few examples.
FormatFloat('0.00E+00 ',2222.22);
The output is 2.22E+03.
FormatFloat('0000.00E+00 ',2222.22);
The output is 2222.22E+00.
FormatFloat('00.0E+0 ',2222.22);
22.2E+2
Look, all zeros to the right of e are dominant.
What does the format mean? The Chinese translation of format is: format; Arrange.
Text analysis:
Format; design
Format; arrange
Reading: English ['f__m_t] USA ['f__rm_t]
Past tense: formatting
Past participle: formatted
Now participle: formatting
Third person singular: format
Common phrases:
Block format is divided into program format and block format.
Check of format check data control program
Region Format Region Form
Example:
This book is designed in a modern format.
This book has been made into a modern format.
This is the same book, but the format is different.
It's the same book.
The format of the meeting is that everyone can ask a question.
The meeting is arranged so that everyone can ask a question.
The disk is too large to format the specified file system.
The disk is too large to format the specified file system.
They arranged the meeting so that each speaker had less than 15 minutes to publish his paper.
They arranged the meeting so that each speaker's speech time would not exceed 15 minutes.
Synonym:
Appearance publishing
Look, look
What does the format mean? Format[ English ]'f_:m_t
[USA ]_f_r_m_t
Layout (of a publication); [From] (data sorting) form; The overall arrangement of TV programs (or plans) ...
Format; Pattern of arrangement; Design layout
Design layout
[Example] Form: Classes are held alternately from Friday to Saturday, with five residential classes.
Form: Classes are held every other Friday and Saturday, including five consecutive classes in the school.
What does the format mean? This dictionary explains the noun n.
1. Format of publications; Format 2. Form of TV, radio, etc. ); Arrangement; Arrangement format
1. form, format
Format form, format
2. One page
Step 3: Size
Format size is a computer term: formatting refers to the operation of initializing a disk or partition in a disk, which usually causes all files in an existing disk or partition to be erased. Formatting is usually divided into low-level formatting and advanced format. Unless otherwise specified, hard disk formatting usually refers to advanced format, while floppy disk formatting usually includes both. .
What does the format mean? Format means 1, formatformat, an English word, which is mainly used as nouns, transitive verbs and intransitive verbs. When used as a noun, it means "format; Layout; Format ",when used as a transitive verb, means" format; The format of the specified format "means" design the format "when used as an intransitive verb.
2. Pronunciation of the format: English [_f__m_t] and American [_f__rm_t]