Order of characters in Free Pascal

1

In Pascal the type char are ordered, and I do not know what that order is. For example, if I have the digit 5 and I want to make it take the value of the integer 5 I do ord('5') ? But does it have that value or is it another? Does anyone have the list of characters in order?

    
asked by Pascal101 22.11.2016 в 17:28
source

2 answers

1

The characters are not sorted because it is PASCAL. There are some tables that convert a numeric coding into characters (hence comes UTF-8, ANSI, ...).

The most basic is the ASCII table, which you can consult for example here . In it appear the basic characters for the English language. If you take a look at the table, you will see that the character '5' corresponds to the value 0x35 in hexadecimal and the '6' corresponds to the value 0x36. This explains that if you add one to the character it seems that you are increasing the value of the number.

With this in mind, and taking a look at the table, it seems obvious to do:

char c := '1';
c := c + 1;

will result in c='2' .

However, this system should not be used to perform mathematical operations and what to do:

char c := '9';
c := c + 1;

It will not result in '10' , and let's not even talk about multiplication.

If you are going to work with numerical values, convert% from% to '5' and work with numbers instead of with characters. A clue: to obtain the number corresponding to a numeric character, simply subtract 5

    
answered by 22.11.2016 в 18:25
0

It's the ASCII code, you have a table here:

link

    
answered by 22.11.2016 в 17:43