Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / mod operator (%) ?

Author
Message
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Apr 2003 19:11
i'm wondering... does the 'mod' operator actually word in dbpro?

Quote: " DB PRO Manual - The MOD specifies that the data on the left side of the MOD is to be divided by the data on the right side of the MOD, and the
remainder of the division is the result:

11 MOD 2 equals 1
A MOD B equals the remainder of the division between A and B"


however when type 'mod' in i'm a little conserned that it isn't recognised by the IDE ... if it isn't there then thats oki, i mean its just

result = (modresult = A/B) but its just more of an annoyance really, and would be aother good example of wanting
#typefunction MOD { value1~&~value2 | &value1/&value2 }
so i can just go result = A MOD B

ho hum eh - it would be good to know if it is there and if it is in the many but not there why is it in the manual? hmm
Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 6th Apr 2003 19:36
In help (F1), principles, then operators:

And yes it does work. As you say, the 'mod' command does not blue in IDE.

The MOD specifies that the data on the left side of the MOD is to be divided by the data on the right side of the MOD, and the remainder of the
division is the result:

11 MOD 2 equals 1
A MOD B equals the remainder of the division between A and B

Gronda, Gronda
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Apr 2003 20:30
you're 100% sure it works right? just wanna make sure before i use it, cause it is disconserting when a feature of dbpro itself doesn't register as one

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 6th Apr 2003 20:50
Yep, tested it fully,

print 10 mod 4 : ` outputs 2
print 100 mod 3 : ` outputs 1

I can't however get floats to work with it, but most of the tine it's only integer division people need. Answer always comes out with 0.

Gronda, Gronda
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Apr 2003 21:16
well thats oki because the mod is suppose to be used on integers only
i mean the calculation i have it

local Caust as dword = ( int(m_fTime/32) mod 32 )

so should be oki (^_^) thanks for testing for me

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2026-07-11 04:23:12
Your offset time is: 2026-07-11 04:23:12