Smashing the previous data

Thread Starter

Ryan$

Joined Dec 14, 2018
178
Hi guys, in any language of programming if for instance defined int x=1; and afterwards x=2; then the previous value of x will be smashed by the new value of x , meaning the final result is x=2 will be stored !

My question, where does the previous data x=1 gone?! how does the PC operate in that case? will he really deleting data when I write on the same byte that I already stored data, or he just write on the same byte without deleting the previous data but just the new data will be stored?! I'm a lil confusing of how does the PC hardware doing that !!
 

dl324

Joined Mar 30, 2015
15,115
in any language of programming if for instance defined int x=1; and afterwards x=2; then the previous value of x will be smashed by the new value of x , meaning the final result is x=2 will be stored !
Your usage of "smashed" to refer to variables being redefined is uncommon.

When you redefine a variable, the original data is replaced by new data.
 

wayneh

Joined Sep 9, 2010
17,175
Computers don't remember anything they're not programmed to store for future use. So unless your program keeps a log of the value of your x variable, only the current state of x is known, not its past or future values.
 

WBahn

Joined Mar 31, 2012
27,410
Hi guys, in any language of programming if for instance defined int x=1; and afterwards x=2; then the previous value of x will be smashed by the new value of x , meaning the final result is x=2 will be stored !

My question, where does the previous data x=1 gone?! how does the PC operate in that case? will he really deleting data when I write on the same byte that I already stored data, or he just write on the same byte without deleting the previous data but just the new data will be stored?! I'm a lil confusing of how does the PC hardware doing that !!
A memory element can only store one value at a time. When you write a new value into it the old value is overwritten and simply does not exist anymore.

Image that your eight bit register consists of eight coins sitting on a table. If the head is showing, it is storing a 1 and if the tail is showing it is storing a 0. Set all eight to something -- perhaps 10011101. Now set them to something else -- perhaps 01011011. What happened to the old values? They are simply gone.
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
A memory element can only store one value at a time. When you write a new value into it the old value is overwritten and simply does not exist anymore.

Image that your eight bit register consists of eight coins sitting on a table. If the head is showing, it is storing a 1 and if the tail is showing it is storing a 0. Set all eight to something -- perhaps 10011101. Now set them to something else -- perhaps 01011011. What happened to the old values? They are simply gone.
You mean that PC is working like once changed then the previous data gone?! isn't it weird data gone? or am I new to PC's operations?! :)

Computers don't remember anything they're not programmed to store for future use. So unless your program keeps a log of the value of your x variable, only the current state of x is known, not its past or future values.
So PC is memoryless and just the present is saved?! really weird :) how data gone once changed
 
Last edited by a moderator:

Thread Starter

Ryan$

Joined Dec 14, 2018
178
A memory element can only store one value at a time. When you write a new value into it the old value is overwritten and simply does not exist anymore.

Image that your eight bit register consists of eight coins sitting on a table. If the head is showing, it is storing a 1 and if the tail is showing it is storing a 0. Set all eight to something -- perhaps 10011101. Now set them to something else -- perhaps 01011011. What happened to the old values? They are simply gone.
I got you very good analogous ! my question for you about "Now set them to " , who does that in PC ... the Computer's hardware?
 

WBahn

Joined Mar 31, 2012
27,410
You mean that PC is working like once changed then the previous data gone?! isn't it weird data gone? or am I new to PC's operations?! :)



So PC is memoryless and just the present is saved?! really weird :) how data gone once changed
No, it is not memoryless. How can it SAVE the present value without memory? You can come back and read that value as many times as you want. Why? Because it is stored in memory. But once you change it, you've changed it.

Each memory element stores the most recent value written to that element.
 

WBahn

Joined Mar 31, 2012
27,410
I got you very good analogous ! my question for you about "Now set them to " , who does that in PC ... the Computer's hardware?
Yes. That's pretty much all a computer does, is store 1's and 0's in various memory locations. Some of those 1's and 0's just happen to be stored in locations where they influence the physical world.
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
No, it is not memoryless. How can it SAVE the present value without memory? You can come back and read that value as many times as you want. Why? Because it is stored in memory. But once you change it, you've changed it.

Each memory element stores the most recent value written to that element.
"once you have change it; you've changed"
I'm with you and totally convinced; so I can say the properties of PC is eliminating the previous data and that because the pc works just with 0/1 and flip between 0/1 ; this operation of flipping is actually "changing to new data and the previous data is gone" ...right?
i
 

WBahn

Joined Mar 31, 2012
27,410
"once you have change it; you've changed"
I'm with you and totally convinced; so I can say the properties of PC is eliminating the previous data and that because the pc works just with 0/1 and flip between 0/1 ; this operation of flipping is actually "changing to new data and the previous data is gone" ...right?
i
For most purposes, that is correct.
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
For most purposes, that is correct.
I'm seeing it a bit weird and something like "imagination" in deleting data, maybe because I'm new in Programming or my brain isn't having that much cleverness to believe in that? because that's really something like magic
 

ericgibbs

Joined Jan 29, 2010
16,389
Morning Ryan,
I suggest you use the term 'over writing data' instead of eliminating or smashing.
As you know in Binary logic there are only two states for a Bit of data, ie: 0 or 1, sometimes named Low or High.
eg: for simple 5V logic, close to zero volts is a '0' [ Low] and +5v is '1' [High].

E
 

LesJones

Joined Jan 8, 2017
3,813
Maybe you can understand if you think of an OR gate that is made with two switches in parallel in series with a light bulb and battery. The state of each switch are the inputs. The output is the state of the lamp. For the inputs we will say that when the switch is closed it is a "1" state. When the switch is open it is a "0" state. For the output if the lamp is lit it is a "1" state. If it is not lit it is a "0" state. If either or both switches are closed (A "1" state.) the lamp will be lit. (A "1" state). If both switches are open (A "0" state) then there is no path for the current so the lamp will not be lit. (A "0" state.) If you wired the switches in series instead of parallel then you would have an AND gate. Both switches would have to be closed for there to be a path for the current so the lamp would light. If you actually build the gates this way and play with them it will get rid of this strange concept of "smashing outputs"

Les.
 

MrChips

Joined Oct 2, 2009
27,137
I would like to use the light switch example.

Someone walks into a room and turns on the switch to the room light. She leaves and turns off the light.
Another person enters the room and turns on the light. He leaves without turning off the light.
Six more persons enter and leave the room, each one choosing to leave the room with the room light in a different on or off state.

You enter the room.
Do you see the light on or off? That is all you know.
You have no way of knowing whether the light was on or off when the previous person entered the room.

This is not an analogy.
This is how it actually works on a computer.
 

WBahn

Joined Mar 31, 2012
27,410
I'm seeing it a bit weird and something like "imagination" in deleting data, maybe because I'm new in Programming or my brain isn't having that much cleverness to believe in that? because that's really something like magic
There's no cleverness or magic involved. When you turn off a light, what happens to the previous "on" that the light had? It's a nonsensical question because the light only "knows" whether it is on right now or off right now. There is no "previous" on to consider.
 

strantor

Joined Oct 3, 2010
6,112
A memory element can only store one value at a time. When you write a new value into it the old value is overwritten and simply does not exist anymore.

Image that your eight bit register consists of eight coins sitting on a table. If the head is showing, it is storing a 1 and if the tail is showing it is storing a 0. Set all eight to something -- perhaps 10011101. Now set them to something else -- perhaps 01011011. What happened to the old values? They are simply gone.
How about hard disks? It's been my impression since forever, that there is some sort of "ghost" of previous data sometimes accessible if you know how to access it. Popular "secure" hard drive wiping methods involve overwriting the HDD several times to ensure that this data is sufficiently corrupt that it can't be recovered.
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
There's no cleverness or magic involved. When you turn off a light, what happens to the previous "on" that the light had? It's a nonsensical question because the light only "knows" whether it is on right now or off right now. There is no "previous" on to consider.
good approach convinced me !
 

WBahn

Joined Mar 31, 2012
27,410
How about hard disks? It's been my impression since forever, that there is some sort of "ghost" of previous data sometimes accessible if you know how to access it. Popular "secure" hard drive wiping methods involve overwriting the HDD several times to ensure that this data is sufficiently corrupt that it can't be recovered.
The TS is struggling with BASIC memory concepts; I saw no reason -- and specifically chose to avoid -- talking about vestigial traces of prior data due to the physical mechanisms to implement memory storage that require Herculean efforts and big bucks to exploit.
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
I would like to use the light switch example.

Someone walks into a room and turns on the switch to the room light. She leaves and turns off the light.
Another person enters the room and turns on the light. He leaves without turning off the light.
Six more persons enter and leave the room, each one choosing to leave the room with the room light in a different on or off state.
I understand here all your story !

but here is the catch:
You enter the room.
Do you see the light on or off? That is all you know.
You have no way of knowing whether the light was on or off when the previous person entered the room.

This is not an analogy.
This is how it actually works on a computer.
If I enter the room then I would see that light maybe off and maybe on ! , if I wanted to lit it and it was lightened?! so just keeping it lightened :)

didn't understand well the second part of your explanation if you could elaborate more then would be much appreciated
 
Top