Dvision with remainders

Blitz3D Forums/Blitz3D Beginners Area/Dvision with remainders

Yo! Wazzup?(Posted 2007) [#1]
How do you do division, but instead of decimals, use remainders?


big10p(Posted 2007) [#2]
Mod returns the remainder of a division, is that's what you mean.


Yo! Wazzup?(Posted 2007) [#3]
I know I’m probably doing something easy to figure out wrong, but I don’t know how to use mod and I’m wondering why the remainder is 0 when I try to do this:
(num1=10 and num2=3)
 num1=Input("First Number: ")
num2=Input("Second Number: ")
answer=num1/num2
Print answer + " r" + num1/num2 Mod 3
Delay 5000
End



Terry B.(Posted 2007) [#4]
I think you simply take the mod then subtract it from the original first number and divide normal then put it in text
Like This:
 

 num1=Input("First Number: ")
num2=Input("Second Number: ")
Nummod = num1 mod num2 ;Divides num1 by num2 as many times as possible and returns remainder
num1 = num1 - nummod
answer = num1/num2
print answer+ " r"+NumMod



H&K(Posted 2007) [#5]
?

10 Mod 2 = 0
10 Mod 3 = 1

10/3 Mod 3 = 3 mod 3 = 0