Thema: Delphi Help translate from C

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Help translate from C

  Alt 18. Aug 2011, 20:54
Delphi-Version: 2010
Code:
int ctoi(char source)
{ /* Converts a character 0-9 to its equivalent integer value */
   if((source >= '0') && (source <= '9'))
      return (source - '0');
   return(source - 'A' + 10);
}

char itoc(int source)
{ /* Converts an integer value to its hexadecimal character */
   if ((source >= 0) && (source <= 9)) {
      return ('0' + source); }
   else {
      return ('A' + (source - 10)); }
}
I don't understand what thes function are doing - convert character to ASCII code and back to character? Nope, I tried Ord/Chr and result was bad. WTF mean number + character statement ?

How to in Delphi? Please?
  Mit Zitat antworten Zitat