Android Question [Solved] Problem with float variable


Active Member
Licensed User
I fill a float-variable in a class with f.i. 1.6 (from a textedit-view)
this is the code, I use:
Public Sub getKlingendicke As Float
    Return mKlingenDicke
End Sub

Public Sub setKlingendicke (dd As Float)
End Sub
I do not understand what happens now: there are decimals altered, although I do not do any calculations with it. I add a screenshot to make that clear:


On the logs-window, you see the altered value. Hoovering over the value shows the exact 1.6
How can I cope with this problem?

Round2 does not change the Situation, everything stayes as before.
Public Sub getKlingendicke As Float
    Return Round2(mKlingenDicke,2)    'Seltsamerweise wird da immer was angehäng an den hinteren stellen.
End Sub
And also strange: When I assign this float-variable back to the text-property of the edittext.view (input type: dezimal_numbers), it is filled correctly with 1.6, ommitting the long decimals.
Last edited:


Licensed User
Longtime User
This is characteristic of both Float and Double values. They are a binary representation of numbers and so cannot aways represent an exact decimal number. It is the same for all computer languages as it is a feature of the computer architecture. Rounding or Formatting the numbers for display usually achieves what you expect.

If you want exact representations see my BigNumbers library.
Upvote 0