Advertisement
Abaduaber

CCToCC

Feb 19th, 2014
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.19 KB | None | 0 0
  1. Const
  2.     AllSymbols:= '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  3.  
  4. Function ExtendedToOtherCC;
  5. Var
  6.     Temp: LongInt;
  7.     Res: String;
  8.     Negative: Boolean;
  9. Begin
  10.     Negative:= Source < 0;
  11.     Res:= ''; Source:= Abs(Int(Source));
  12.     While Source >= BaseOfCount Do Begin
  13.         Temp:= Trunc(Source - Int(Source / BaseOfCount) * BaseOfCount);
  14.         Source:= Int(Source / BaseOfCount);
  15.         Res:= AllSymbols[Temp + 1] + Res;
  16.     End;
  17.     Temp:= Trunc(Source - Int(Source / BaseOfCount) * BaseOfCount);
  18.     Res:= AllSymbols[Temp + 1] + Res;
  19.     If Negative Then Res:= '-' + Res;
  20.     ExtendedToOtherCC:= Res;
  21. End;
  22.  
  23. Function OtherCCToExtended;
  24. Var
  25.     P, Temp: Word;
  26.     CurSymbols: String;
  27.     OutPut, Count: Extended;
  28. Begin
  29.     P:= Length(Number); OutPut:= 0; Count:= 1;
  30.     CurSymbols:= UpperCase(Copy(AllSymbols, 1, BaseOfCount));
  31.     While P >= 1 Do Begin
  32.         For Temp:= 1 To BaseOfCount Do Begin
  33.             If CurSymbols[Temp] = Number[P] Then Begin
  34.                 OutPut:= OutPut + Count * (Temp - 1);
  35.                 Count:= Count * BaseOfCount;
  36.                 Break;
  37.             End;
  38.         End;
  39.         Dec(P);
  40.     End;
  41.     OtherCCToExtended:= OutPut;
  42. End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement