TrisectDevelopment Active Member Licensed User Longtime User Mar 19, 2014 #1 I'm having a problem with numbers. I have the number 4.567 and I only want the number 4. Examples: Number what I want 4.434 4 4.678 4 3.212 3 3.898 3 You get the point! Is this possible? I tried Round and Round2 and some other stuff found on the forum, but I cant figure it out.
I'm having a problem with numbers. I have the number 4.567 and I only want the number 4. Examples: Number what I want 4.434 4 4.678 4 3.212 3 3.898 3 You get the point! Is this possible? I tried Round and Round2 and some other stuff found on the forum, but I cant figure it out.
eps Expert Licensed User Longtime User Mar 19, 2014 #2 You're not rounding though are you... If you set the number to a string and then just substring or trim it from the beginning of the string up to the position of the decimal place, then that should do the trick. or floor http://www.b4x.com/android/forum/threads/rounding-a-decimal.15776/#post-134001 Upvote 0
You're not rounding though are you... If you set the number to a string and then just substring or trim it from the beginning of the string up to the position of the decimal place, then that should do the trick. or floor http://www.b4x.com/android/forum/threads/rounding-a-decimal.15776/#post-134001
M Mahares Expert Licensed User Longtime User Mar 19, 2014 #3 You can also use the Floor function as shown below: Code: Copy Dim x As Double=3.898 If x > 0 Then Msgbox(Floor(x),"") 'displays 3 if number = 3.898 Else Msgbox(Ceil(x),"") 'displays -3 if number = -3.898 End If Upvote 0
You can also use the Floor function as shown below: Code: Copy Dim x As Double=3.898 If x > 0 Then Msgbox(Floor(x),"") 'displays 3 if number = 3.898 Else Msgbox(Ceil(x),"") 'displays -3 if number = -3.898 End If
mangojack Expert Licensed User Longtime User Mar 19, 2014 #5 Agree with eps ..TD is not really wanting to round off .. just wants the first digit / digits . (going on example) So for simplicity .. why could you not just send to integer ? Code: Copy Dim d1 As Double = 4.434 4 'Dim d2 As Double = 4.678 4 'Dim d3 As Double = 3.212 3 'Dim d4 As Double = 3.898 3 Dim i As Int = d1 Log (i) ..' tried to get an array going , but getting late (again !) Last edited: Mar 19, 2014 Upvote 0
Agree with eps ..TD is not really wanting to round off .. just wants the first digit / digits . (going on example) So for simplicity .. why could you not just send to integer ? Code: Copy Dim d1 As Double = 4.434 4 'Dim d2 As Double = 4.678 4 'Dim d3 As Double = 3.212 3 'Dim d4 As Double = 3.898 3 Dim i As Int = d1 Log (i) ..' tried to get an array going , but getting late (again !)
eps Expert Licensed User Longtime User Mar 19, 2014 #6 Floor will work as required, I'd already mentioned it as well in my post. Upvote 0
TrisectDevelopment Active Member Licensed User Longtime User Mar 19, 2014 #7 Thanks alot Guys! I did not think about floor, and I already new the command. But totally forgot about it. Last edited: Mar 19, 2014 Upvote 0
Thanks alot Guys! I did not think about floor, and I already new the command. But totally forgot about it.