Restored from previous forum. Originally posted by pusztry.
Is there a built in Modulo function for PB?
If there is not is there another way to get at the remainder of division?(the long way)
Ex:
5%10 or 5 mod 10
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
Modulo Function
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by pusztry.
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
What is the math?:evil:Originally posted by Paul
If you don't want to do the math... you could do it the easy way by using IMod() found in the MathExtra ASM Library. (get it from the Resources Site)
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Something like this...
So the MOD of 14/4 will return 2...
4 goes into 14 three times with a remainder of 2
Something like this...
Code: Select all
Procedure.l Mod(value.l,divisor.l)
v1=value/divisor
v2=v1*divisor
result=value-v2
ProcedureReturn result
EndProcedure
MessageRequester("",Str(Mod(14,4)),0)
4 goes into 14 three times with a remainder of 2
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Thats what i use:

cya,
...Danilo
(registered PureBasic user)
Thats what i use:
Code: Select all
Procedure.l MOD(a,b)
ProcedureReturn a-a/b*b
EndProcedurecya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.

Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
As long a future release of PureBasic does the math in the correct order without parenthesis...Originally posted by fweil
...
until now but will change with Danilo's to save 2 assembler steps !
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm