Skip to main content
added 316 characters in body
Source Link

I am not an expert in the field, but I can try to give an approximately correct answer.

You have to understand structure of data in computer memory. Reading from memory itself, you can not diferentiate between lets say ints and characters. The compilercompiled program is compiled with locations of where to find the thingoperator that tells "print" operationis needed, in this case print for ints and for chars. You must specify how to represent thethat data, in form of a number or a character. Basically, theyour print operator gets the info of what is the data type in that memory location, and displays it appropriatellycommand.

Example in c:

printf("ASCII value = %d, Character = %c\n", ch , ch );

This code will first represent data at location ch as a number and than as a char. Hopefully

Let me give another example: Let us say that your language can "add" strings, in form of concatenating one onto another. How can computer know which "add" to use, if you cannot learn of data type from memory? The compiler compiled the program with address to the appropriate "add" command, according to data type you specified your operands to be.

Moral of the story: you cannot learn of data type from memory. Hopefully this clears it out.

I am not an expert in the field, but I can try to give an approximately correct answer.

You have to understand structure of data in computer memory. Reading from memory itself, you can not diferentiate between lets say ints and characters. The compiler is the thing that tells "print" operation how to represent the data, in form of a number or a character. Basically, the print operator gets the info of what is the data type in that memory location, and displays it appropriatelly.

Example in c:

printf("ASCII value = %d, Character = %c\n", ch , ch );

This code will first represent data at location ch as a number and than as a char. Hopefully this clears it out.

I am not an expert in the field, but I can try to give an approximately correct answer.

Reading from memory itself, you can not diferentiate between lets say ints and characters. The compiled program is compiled with locations of where to find the operator that is needed, in this case print for ints and for chars. You must specify how to represent that data in your print command.

Example in c:

printf("ASCII value = %d, Character = %c\n", ch , ch );

This code will first represent data at location ch as a number and than as a char.

Let me give another example: Let us say that your language can "add" strings, in form of concatenating one onto another. How can computer know which "add" to use, if you cannot learn of data type from memory? The compiler compiled the program with address to the appropriate "add" command, according to data type you specified your operands to be.

Moral of the story: you cannot learn of data type from memory. Hopefully this clears it out.

Source Link

I am not an expert in the field, but I can try to give an approximately correct answer.

You have to understand structure of data in computer memory. Reading from memory itself, you can not diferentiate between lets say ints and characters. The compiler is the thing that tells "print" operation how to represent the data, in form of a number or a character. Basically, the print operator gets the info of what is the data type in that memory location, and displays it appropriatelly.

Example in c:

printf("ASCII value = %d, Character = %c\n", ch , ch );

This code will first represent data at location ch as a number and than as a char. Hopefully this clears it out.