In my Class I have a attribute, fileSize
The type is long
I don’t want to change to float/double, cause I work with databases and now I can’t just edit
the datatypes (to late)
the filesize is normally in kB (Reason why long)..
But once I want to show it in MB (that would be, fileSize / 1024) -> and I get 0, its because the type isn’t float/double..
How I can solve the problem, so that I get b.E 0.54MB without changing the DataType of fileSize?
fileSize / 1024performs integer division since both operands are integers. If you want to perform real division you could do this (at least one of the operands must be a real number):or:
Now result will contain the correct value that you want to print on the UI.