How do I reset a Real4 variable back to it's original state? I have Value Real4 ?
in my data section and I performed an FADD operation and stored the result like so FST Value
. I want to use Value again for something else, how do I reset Value?
Asked
Active
Viewed 636 times
0

Yumeii Chii
- 23
- 3
-
2Add a new temporary variable in your data section, and copy the value to the temporary variable. Never overwrite the original value. – Nayuki May 07 '16 at 21:51
-
1Or undo the addition, but that's silly :) – Jester May 07 '16 at 21:51
-
@Jester Unfortunately due to round-off error, floating-point addition and subtraction will not necessarily restore the original number. As an artificial example, [(2 + 1000000) − 1000000] = [1000000 − 1000000] = 0. – Nayuki May 07 '16 at 23:21
-
1@Nayuki lucky that I didn't say undo it with the subtraction of the same amount :D – Jester May 07 '16 at 23:36
-
@Jester I am curious, how else can you undo the addition? – Nayuki May 07 '16 at 23:37
-
1@Nayuki Thank you- I did that and it worked. My instructor mentioned efficiency so I was afraid of adding more variables. I thought there was another way to reset a variable without adding more variables. – Yumeii Chii May 08 '16 at 01:46
-
2Load your value from memory onto the FPU stack, then make a copy of it on the FPU stack. – Michael Petch May 08 '16 at 02:18
-
@YumeiiChii For most tasks in computer programming, the first priority is to write correct working code. Only after that is done, would we consider the question of efficiency. =) – Nayuki May 08 '16 at 02:23
-
1@Nayuki ; I pretty much said the same thing recently in an x87 question PeterCordes and I wrote about: http://stackoverflow.com/a/36926441/3857942 .I think understanding the FPU stack, and getting working code going should be the first priority. once that is done then work on the efficiencies. – Michael Petch May 08 '16 at 02:44
-
Store the result somewhere else? – David Hoelzer May 08 '16 at 08:36