Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Converting one number to another.
- TheHockeyist
-
1000+ posts
Converting one number to another.
I don't mean like “multiply by 2, divide by x” sort of stuff. I'm coding in a project that randomly generates two 6 digit numbers using 7's and 8's (the project's equivalent of 0's and 1's). The first result is “old” and the second is “new”. And each of the 64 possible combinations needs to be translated into a number from 1-64. How do I do that?
I could do
But I cannot do that for some reason. Can anyone help me to convert one number to another? I need to do this for both of my “old” and “new” variables which are set up in 6-digit format.
I could do
But I cannot do that for some reason. Can anyone help me to convert one number to another? I need to do this for both of my “old” and “new” variables which are set up in 6-digit format.
- drmcw
-
1000+ posts
Converting one number to another.
Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
- TheHockeyist
-
1000+ posts
Converting one number to another.
It has to be. Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
- drmcw
-
1000+ posts
Converting one number to another.
Unless you can come up with a mathematical function that relates the two number systems then a huge if then else switch statement is one way to go the other would be to fill a list with the numbers then find the number in the list and it's index is the converted number.It has to be. Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
- TheHockeyist
-
1000+ posts
Converting one number to another.
Thanks.Unless you can come up with a mathematical function that relates the two number systems then a huge if then else switch statement is one way to go the other would be to fill a list with the numbers then find the number in the list and it's index is the converted number.It has to be. Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
- TheHockeyist
-
1000+ posts
Converting one number to another.
I've inserted the list now,
item 1 = 777777
item 2 = 888888
…
item 64 = 878787
But how do you check the location of something in the list?
item 1 = 777777
item 2 = 888888
…
item 64 = 878787
But how do you check the location of something in the list?
- TheHockeyist
-
1000+ posts
Converting one number to another.
Nevermind, the code is working now. I'm going to report this to be closed.
- Discussion Forums
- » Help with Scripts
-
» Converting one number to another.