I isk2837 Member Licensed User Longtime User Apr 5, 2012 #1 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?
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?
M Mahares Expert Licensed User Longtime User Apr 5, 2012 #2 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
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
A admac231 Active Member Licensed User Longtime User Apr 5, 2012 #3 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
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.
barx Well-Known Member Licensed User Longtime User Apr 5, 2012 #4 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 Apr 5, 2012 #5 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
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"