WML to do integer divide on a variable

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

WML to do integer divide on a variable

Post by toms »

I think there is no way to find out if you can divide a variable and a number without fraction stuff comes out.
I invented a macro for this. I don´t know sure if it would work.. :?

Code: Select all

#define CHECK_DIVIDE VAR ARG LIMIT
{VARIABLE_OP {VAR} divide {ARG}}
[while]
[variable]
name=divide
equals=no
[/variable]
 [do]
  [if]
  [variable]
  name=number
  numerical_equals=${VAR}
  [/variable]
   [then]
   {VARIABLE dividable yes}
   {VARIABLE divide yes}
   [/then]
   [else]
   {VARIABLE_OP number add 1}
    [if]
    [variable]
    name=number
    numerical_equals={LIMIT}
    [/variable] #when this has no limit 
and the number is not divideable, then the computer won´t get out of the loop!
     [then] 
      {VARIABLE divide yes}
      {VARIABL dividable no}  #this stops the repeat
     [/then]
    [/if]
   [/else]
  [/if]
 [/do]
[/while]
:wink:
Last edited by toms on March 9th, 2006, 3:07 pm, edited 1 time in total.
First read, then think. Read again, think again. And then post!
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

So, basically, this macro divides a number and gives rounds the answer down? i.e., 9/4 -> 2, not 2.25?

What's the point of this? How would it be used?...
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

No. It checks if you can do integer divide (I found the name :D ) without rests with a variable by using a number you can choose.

Example: It says that 9/4 "cannot" be divided, and 8/4 could.
And the use... :? . I thought before that I need this, but I don´t and at this time, I didn´t had this idea. Maybe another guy can use it. :wink:
First read, then think. Read again, think again. And then post!
Post Reply