divided wrong

Programming related discussions related to game research
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

divided wrong

Post by Shokoniraya »

Code: Select all

math SIZEQ = 17
if SIZEQ / 16
print "%SIZEQ%"
endif
break

you can see, i post a very simple code
if SIZEQ divided by 16, then print it. but must print nothing. what is the wrong?
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: divided wrong

Post by Delutto »

Code: Select all

math SIZEQ = 17
xmath MOD "SIZEQ % 16"
if MOD = 0
   print "%SIZEQ%"
endif
aluigi wrote:
There's a "if not" instruction?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: divided wrong

Post by aluigi »

Just replace / with % and it works.
You also have an useless "break" there.

17 / 16 = 1
16 / 16 = 1
17 % 16 = 1
16 % 16 = 0
It's just math :)
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: divided wrong

Post by Delutto »

aluigi wrote:Just replace / with % and it works.
But it'll do the opposite, that's why I asked you for a "if not" like instruction.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: divided wrong

Post by aluigi »

Ah sorry, I replied to Shokoniraya only.

Anyway you are right, there is no "if not".
I just use "if ... else" for handling these cases.