Page 1 of 1
Posted: Wed Aug 28, 2002 3:35 am
by BackupUser
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
Posted: Wed Aug 28, 2002 3:45 am
by BackupUser
Restored from previous forum. 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)
Posted: Wed Aug 28, 2002 4:03 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.
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)
What is the math?:evil:
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
Posted: Wed Aug 28, 2002 4:49 am
by BackupUser
Restored from previous forum. Originally posted by Paul.
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)
So the MOD of 14/4 will return 2...
4 goes into 14 three times with a remainder of 2

Posted: Wed Aug 28, 2002 5:20 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.
Thats what i use:
Code: Select all
Procedure.l MOD(a,b)
ProcedureReturn a-a/b*b
EndProcedure
cya,
...Danilo
(registered PureBasic user)
Posted: Wed Aug 28, 2002 5:58 am
by BackupUser
Restored from previous forum. Originally posted by Paul.
LOL... Danilo makes my code look bloated
Oh well, we'll say I was trying to break it down to show what's going on... hehe

Posted: Wed Aug 28, 2002 8:18 am
by BackupUser
Restored from previous forum. Originally posted by fweil.
...
Funny ... I was using
Procedure.l IMod(a.l, b.l)
ProcedureReturn a - (b * (a / b))
EndProcedure
until now but will change with Danilo's to save 2 assembler steps !
Have a nice day.
Francois Weil
14, rue Douer
F64100 Bayonne
Posted: Wed Aug 28, 2002 6:10 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Originally posted by fweil
...
until now but will change with Danilo's to save 2 assembler steps !
As long a future release of PureBasic does the math in the correct order without parenthesis...
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Posted: Thu Aug 29, 2002 12:01 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.
That helps.
Thanks
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra