Help with dividing numbers in a different way

isk2837

Member
Licensed User
Longtime User
I know how to divide one number by another, but how do I do it in a way that only keeps the number of times that x divides into y, without the remainder?
 

Mahares

Expert
Licensed User
Longtime User
Are you thinking something simple like this using Round:
B4X:
Dim var1,var2 As Double
Dim varResult As Int
var1=74
var2=17
varResult= Round(var1/var2)
Msgbox(varResult,"")

It yields: VarResult=4 without decimals
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
That will will show the answer rather than the amount of times x divides into y.

If I understand you correctly, this should do it:

B4X:
Dim a As Double
a = Floor(Logarithm(x,y))

With this, if x = 15 and y = 2 then a = 3.

And Mahares example - x = 71 and y = 17 then a = 1.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Ahh the integer divide "/" function.

Can't say I've seen it in b4a. I'm usually wrong though. ;)
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Just checked it out and yes it does work.

B4X:
dim x, y, Result as int

x = 45
y = 4

Result = x / y

log("Result = " & Result)

Show in log "Result = 11"
 
Upvote 0
Top