Android Question Rouns2 Question

grant1842

Active Member
Licensed User
Longtime User
I am doing some math.

B4X:
Sub btCalc_Click
  
    '468= half wavelength
    '234 quarter wave length
  
    Dim  num1 = 234 As Float  'wavelength
    Dim  num2 = 7.200 As Float 'frequency
  
    Result = num1 / num2 '32.5
    Result2 = Result * 10 '3.25
    sum = (Result2 + Result)
    edResult.Text= Round2(sum,2)
  
End Sub
The sum = 357.5
I need to format the sum to look like 35.75
Thanks for your help.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Why do you multiply Result by 10? that makes it 325 instead of 32.5. Maybe you meant to divide by 10?

--- Jem
 
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
The multiply is correct . I just need to round the sum to display correctly.
Thanks for your comment
 
Upvote 0

HotShoe

Well-Known Member
Licensed User
Longtime User
Then you'd need to multiply by .10

Round2 won't help with converting a number, only with the number of decimal places to display.

--- Jem
 
Upvote 0
Top