This is a four-round function, specific usage myround (1.999, 2) = 2.00 The first bit 1.999 is the number of rounds to be rounded, 2 is the decimal place to take.
Welcome everyone to test. QQ: 81392790
Function myround (const yuan: integer): extended; // an: The original floating point number, PP retains the second number of VAR P, L, M, L2: longint; s: String; // Points SQ: String; // Decimal Point SH: String; // Decimal point Begin if Yuan = 0 THEN EXIT; // Original floating point number 0 IF PP <0 THEN EXIT; // The second few digits after the illegal decimal point s: = floattostr (yuan); p: = POS ('.', s); // decimal point position SQ: = MIDSTR (S, 1, p-1); sh: = midstr (S, P 1, Length (s) - Length (SQ) -1); L: = Length (sh); // Dumer number L2: = Length (sq); // Integer number if PP> = l1n begin // 0 Result: = strawloat (s ); Exit; //, such as 11.06, the third place to retain the decimal point, obviously unreasonable end; // {if pp = L THEN //, such as 11.06 To retain the second digit after the decimal point, the second place does not have to return to Begin // 1 results: = S; EXIT; END; // 1} if PP