Created
April 9, 2014 19:04
-
-
Save kpmy/10303759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROCEDURE IntToString* (x: LONGINT; OUT s: ARRAY OF CHAR); | |
VAR j, k: INTEGER; ch: CHAR; a: ARRAY 32 OF CHAR; | |
BEGIN | |
IF x # MIN(LONGINT) THEN | |
IF x < 0 THEN s[0] := "-"; k := 1; x := -x ELSE k := 0 END; | |
j := 0; REPEAT a[j] := CHR(x MOD 10 + ORD("0")); x := x DIV 10; INC(j) UNTIL x = 0 | |
ELSE | |
a := minLongIntRev; s[0] := "-"; k := 1; | |
j := 0; WHILE a[j] # 0X DO INC(j) END | |
END; | |
ASSERT(k + j < LEN(s), 23); | |
REPEAT DEC(j); ch := a[j]; s[k] := ch; INC(k) UNTIL j = 0; | |
s[k] := 0X | |
END IntToString; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment