# 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.

### 2D All the way! / modular arithmatic problem

Message
Posted: 6th Jul 2003 22:23
Ok this is the problem i've been having, it's on modular arithmatic so called "clock math" it's real simple to do in c,c++,or visual basic, but i've been trying to find a function or operator so i can do it in dark basic for a 2D game i'm working on. This is what it does: Think of a clock, u start at 1 and as time goes on the time goes like 1,2,3,4 etc... anyways you get to 12, but after that it is'nt 13 it's 1 again. anyways in c++ you would write that statment as x % 12 (x being the number of hours so far) in visual basic you would write it as x mod 12, they both give the same effect. So for an example what would happen if we had x % 2 the number line would go like 0,1,2,0,1,2 etc... everytime it reaches 3 returning to 0. Anywas that's what it does, if anyone knows about a fuction or operator that performs this operation please tell me. [b])
Sparing - Loved by many Pefected by few.
Posted: 6th Jul 2003 22:36
What, you mean like the mod operator? Why didn't you just try it?

a=x mod 12
Posted: 6th Jul 2003 22:44
i did, it came up with a compilation error "unknown command" and the line that had the "mod" command in it. I have DBC so i'm hoping it's not somthing with pro.

Sparing - Loved by many Pefected by few.
Posted: 6th Jul 2003 22:58
It only works in DBPro
In classic you would have to code your own function to do this.

Posted: 6th Jul 2003 23:11
do u know how to code it or would i have to make it up myself? (I do know how to make one, but it has a loop statment in it and it would suck a ton of memory if i was dealing with real big numbers. Here is the code i would use if i had to make my own:

Sparing - Loved by many Pefected by few.
Posted: 6th Jul 2003 23:13
You should have said DBC so that I wouldn't get arsey

Posted: 7th Jul 2003 17:50
thanks for your help IanM, i'm prety sure i'll be using that code in one of my programs.

Sparing - Loved by many Pefected by few.
Posted: 7th Jul 2003 22:07
I'll be needing that as well. To cool...

"I need gopher-chucks!!"