how do i reverse a precise constant number down into decimals....
in the image you can see 2 sliders 1 is just a number 1 the other is decimal slider, -0.20 is to set that 1 to 0.01 if you set the decimal slider to 0.2 then that would add the 1 to 100.00 from here you can make numbers like 000.01/000.10/001.00 and so on.
my question is how do i reverse this like the number 111.11 then if the decimal slider is at -0.2 then as a output to only output the 000.01 number and not the others.
e.g number = 111.11 decimale slider is at -0.2 so = 000.01, if the number is 111.10 then the 000.01 will be 000.00.
if decimal is 0.2 then the 000.01 will be 100.00 as an output instead.
the point of this is so that each digit can be either a 0 or 1 so it can remember 5 things in 5 digits in 1 variable instead of using 5 variables in a game that could use 100+.in total
-
Hiya
I can't help with your problem but I'll suggest an alternative!
I get what you mean about having lots of variables so look up Local Variable by Serikos. It's dead simple ( 4 nodes and a logic gate ) but acts as local storage for a numeric value. Stamp it and rename it and you can easily store 100+ variables with very little effort.
Good luck with your binary math too. -
It's a little hard to follow the logic in the screenshot, so forgive me if I've misunderstood. I think what you're trying to do is start at some given number, and get a single digit from it--is that right? The binary stuff would get a whole lot more complex, but if you're okay with just storing a 1 or 0 at each position of a normal value, that's okay by me. If so, here's how I would do it:
First thing to do is use the n^x mode of the calculator. Set the top to 10, and the bottom to some integer. Just so we're on the same page, 10^2 = 100. 10^1 = 10. 10^0 = 1. 10^-1 = 0.1.
Now we can use such numbers in our calculations. We need two things: to get the value from the position we want down, and also to get the value from the position just below the one we want down--to remove it from the number afterwards. We can do this in either order just so you know. But I'll explain it in a particular order just so I can keep track.
So say we have the number 1.234, and we want the number at the second decimal place--the 3. We first need to get rid of the stuff "above" it. So we can use the remainder mode of a calculator. We need to find the remainder for dividing by a value at the position just above the 2nd decimal. To do this, use another calculator to take the decimal position (-2) add 1 to it (-1), then plug that into a power calculator (10^-1) to get 0.1. Now find the remainder of the original value by that 0.1. The value 1.234 can divide evenly into 0.1 some number of times, with 0.034 left over.
Now we find what's "below" the position we want. Take the position (-2) and plug it into a power calculator (10^-2) to get 0.01. Find the original value's remainder after dividing by 0.01 to find the value below the position we want. 0.034 divides evenly into 0.01 with the remainder 0.004.
Next subtract that from 0.034 and you get... 0.03. Then you can move that value up by the right number of spaces using another power calculator. Multiply the decimal position by -1, to flip it into positive (or if it was positive, flip it into negative), then plug that into a power calculator (10^2) to get 100. Multiply your value by that (0.03 x 100) to get the result: 3.
This method should work for any position in the decimal or integer side of a value. And you could probably tweak it so you can use it for binary--though I've not worked with binary calculations by hand, so I'll leave that to you to figure out.
Something to be aware of is that you will likely get floating point errors that may mess with your values at smaller decimals. So it could be worth instead multiplying it all up so that the position you want is an integer (so instead of 1.234, raising it up to 123.4). This would make some calculations easier also, maybe. -
At this time the limit is 128 values. If this is not enough, there are tricks to expand this. I made some logic which stores and retrieves 4 values into one variable:
"Variable expander: 4 values" (https://indreams.me/element/obQCZftfagj)
OgTheEnigma made "Persistent Binary Array Concept" (https://indreams.me/element/obLBCAgUMJz).
I might make a 24 boolean true/false remix of mine.
You are trying to do the same trick, but with decimals instead of binary numbers. Computers work with binary, so doing it with decimals is more prone to rounding errors, which might mess everything up. -
Okay, I made: "Variable expander: 24 true/false values" (https://indreams.me/element/oiBqUfaWWwQ)
iniciar sessão para comentar.