Casting memory usage? [WITH]

It is rather a matter of theory, and then any actual code. I understand that if you declare an int i variable; then it allocates 4 bytes in memory for the integer i. I understand if you use malloc to create your memory.

I am curious how memory is processed when you do something like

int x;
int y;
double z;

z = (float)x/(float)y;

When you perform a similar action, how memory is processed. Does the program create a float and save x and y and then do the splitting? Or is it something out of memory?

Thanks for any explanation!

+3
source share
2 answers

, - - . . , .

+2

, , . , sizeof(int) 4, .

( ):

fild [x] // load x from the stack into a register
fidiv [y] // divide by y loaded from the stack
fstp [z] // store the result in z

FPU.

0

Source: https://habr.com/ru/post/1731881/


All Articles