The Daily Click ::. Forums ::. Klik Coding Help ::. Formula Help
 

Post Reply  Post Oekaki 
 

Posted By Message

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
9th November, 2008 at 10:13:17 -

Just thought I'd ask for some help on nutting out a formula for this problem:

You have a counter that starts at one, and always adds one to itself until it gets to 144.

Then you have another counter that always adds one to itself, but when it reaches 12 it sets itself back to 1, so it goes like this: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11.... Until the other counter reaches 144.

What I want to know is this: A formula that converts the number from the first counter, into the number from the second counter.. example: The first counter is at 43, so set the second counter to 7.

The thing is, 144 can be replaced by anything and 12 can also be replaced by anything. The only rule is that the "144" must be a multiple of the "12". So it could be "100" and "5", where the first counter is at 57, so set the second counter to 2.


If you can understand what I mean, any help would be appreciated

 
n/a ...

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
9th November, 2008 at 10:35:21 -

That's not easy to understand.

The solution however, I give you in 3 words.
value("Counter1") mod maxvalue("Counter2")


For your example, it's
Counter1 Mod 12


 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
9th November, 2008 at 11:03:19 -

I don't know how noobish this sounds but I'm not quite familiar with the term "mod" I think after a bit of thinking I've fixed my problem, however.

X-(Y*(Floor(X/Y))

//Where X is counter 1, and Y is counter 2.

Will always give me the correct value, whatever numbers I substitute into the equation


So, using the numbers from my first post:
43-(12*(Floor(43/12)) ...Will give me 7.

I'm just converting a position in a dynamic array to a column in an easy grid


This always happens, I get so frustrated with a problem so I post for help on TDC, then I go back to it and an answer is staring me right in the face. It might be something to do with thinking about my problem as I type it out.

 
n/a ...

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
9th November, 2008 at 11:18:26 -

Uh, just use mod. It's literally mod in MMF.
X mod Y. That's it.
43 mod 12 = 7
99 mod 12 = 3
144 mod 12 = 0
54 mod 12 = 6

Don't use complex formulas, they'll come back and screw you in the future. Not knowing mod is fine (though they should teach it in school, after division). Using a complex formula when there's an easy one is noobish. It's like the noob who adds a lens flare in Photoshop because he thinks it makes him elite

I get what you mean about posting problems, though. I end up arguing about people about formulas and stuff, and that makes me realize the obvious

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
9th November, 2008 at 13:07:14 -


Originally Posted by -Julian-

X-(Y*(Floor(X/Y))


That's funny, because that's exactly what the mod operator does. It returns the remainder after a division.
I agree with Muz, don't go making things harder for yourself, just use the mod function

 
This space is for rent

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
10th November, 2008 at 07:49:55 -

I will just use the mod function then I guess I accidently discovered it on my own.. So much for teaching it in school

 
n/a ...
   

Post Reply



 



Advertisement

Worth A Click