Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If type of the value cannot be analyzed by looking into the bits, how does the machine know how the value should be manipulated?

Tags:

c++

c

If type of the value cannot be analyzed or found out by looking into the bits(As written in books I have referred), how does the machine know how the value should be manipulated?

like image 219
Frog Avatar asked Nov 27 '22 11:11

Frog


2 Answers

C and C++ are statically typed, meaning that types are a compile-time concept. The compiler generates code to manipulate the bits in a manner appropriate to the type; the machine executes that code, and doesn't need to know anything about the type.

like image 185
Mike Seymour Avatar answered Dec 19 '22 05:12

Mike Seymour


The compiler knows the type of every variable because you must declare each type. So the compiler generates the appropriate instructions for dealing with a variable of any particular type.

like image 44
ScottMcP-MVP Avatar answered Dec 19 '22 05:12

ScottMcP-MVP