Quote:Also, I just remembered another question, that's been bugging me for a while. What happens with parameters passed by reference? I know what happens, I just don't know how! :p
Instead of passing a parameter by value, as in
pushing it on the stack, you instead push its memory location onto the stack. The callee will then be able to read from or write to this location, and changes will be kept after returning.
In your case it would be something like:
stack.push( PointerToInt ); // as in _stack[0].type = PointerToIntstack.push( & myInt ); // as in _stack[0].data = int( & myInt );
It should be noted that storing a pointer in an integer could result in loss of data (for example on non 32-bit systems), so it's probably wiser to use other means to implement a data store. For example, you could map data to memory directly:
*reinterpret_cast<int *>( baseMem + offset ) = myInt;
Quote:Well as I said, the data is stored as an int. Does this mean I have to have two bits of memory? An int for the mantissa, and an int for for exponent? Even so, I would have no clue then how to turn a regular float into these two forms..
A 32-bit floating-point number can be stored (and consequently restored) perfectly in a 32-bit integer data type. In C++, this could go like so:
*reinterpret_cast<float *>( & myInt ) = myFloat; // storemyFloat = *reinterpret_cast<float *>( & myInt ); // restore
Please, correct me if I made any syntactical mistakes. I'm in a bit of a hurry :-).