HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to check if a hero's level is divisible by a number...

04-26-2008, 01:10 AM#1
Av3n
Like the thread suggest my maths ain't as good as most people so here I am.

How do you check if a hero's level is divisible by a number. For example 5?
I haven't worked out any formulas on working this out so can you guys please help me. Its to check if the hero is level is divisible by five so I can add bonuses when it is

-Av3n
04-26-2008, 01:48 AM#2
TheDamien
level mod 5 == 0.
04-26-2008, 03:07 AM#3
Rising_Dusk
Collapse JASS:
if ModuloInteger(GetHeroLevel(MyHero), someInteger) == 0 then
    //Divisible evenly
else
    //Not Divisible evenly
endif
04-26-2008, 03:09 AM#4
Av3n
Thanks for the help

-Av3n
04-26-2008, 05:17 PM#5
ADOLF
if "some integer" == 4 or another 2^n then
Collapse JASS:
//is div 4
if level*0x40000000==0x00000000then

ModuloInteger - not true function^^
04-26-2008, 07:41 PM#6
EnderA
Quote:
Originally Posted by ADOLF
ModuloInteger - not true function^^

Maybe I'm misunderstanding what you mean, but ModuloInteger(<Dividend>, <Divisor>) is indeed a function.
04-26-2008, 07:44 PM#7
Vexorian
Quote:
ModuloInteger - not true function^^
It is a function...
04-26-2008, 11:57 PM#8
Toadcop
Quote:
if level*0x40000000==0x00000000then
overflow O_o ? kind a weird... need to test.
04-27-2008, 12:29 AM#9
PandaMine
Quote:
Originally Posted by Toadcop
overflow O_o ? kind a weird... need to test.

Very odd indeed
04-27-2008, 03:09 AM#10
Gorman
This works aswell right?

If (Level) / (integer) equal to Int((Level) / (integer))
Then
it is divisible
Else
it is not!
04-27-2008, 03:49 AM#11
Vexorian
Quote:
Very odd indeed
It's just obfuscation for a right shift
04-27-2008, 09:29 AM#12
ADOLF
Quote:
It is a function...
Had to a kind that it fucking BJ... imho it must be inline: if i==i/a*a then ...
Quote:
Very odd indeed
because it many people count my code confusing (difficultly readable)

Quote:
overflow
why not?)
04-27-2008, 09:50 AM#13
Malf
Quote:
Originally Posted by Gorman
This works aswell right?

If (Level) / (integer) equal to Int((Level) / (integer))
Then
it is divisible
Else
it is not!

You are comparing something to itself! Good job!

A.K.A you are wrong.