How can I display a calculated number in a label as a percentage?
Example: .243687 in my label, i want it to read 24.37%
labelpercent.text = ((label1.text - label2.text ) / label1.text)
i want labelpercent.text to be XX.XX%
in visual basic i used:
labelpercent = Format((label1 - label2) / label1, "percent")
that worked great in vb, i am very new to basic4android, still on trial version
this is what worked well for me in visual basic
lblpercent = Format ((lblratio1 - lblratio2) / lblratio1, "percent") this gave me the actual percent of drop from ratio1 to ratio2 , like 25.89%
so far all i am getting my label to display is 0.25% when i need it to display 25.89% (example)
To my understanding, NumberFormat2 will be more accurate than Round2 for precise calculations.
Is there any issue however, while using Round2 when the result doesn't have to be that precise?
Most of us are taught that for digits below 5, round down, for 5 and greater round up.
Let imagine you're building a Forex Trading app, where a price variation of 1/100th of a cent (depending on the invested value) will result in profits/losses of thousands of dollars.
Would you perform calculations using NumberFormat2 in this app, without hesitation?
I'm afraid that you are confusing things.
You should use Round if you want to round a numeric value, Round returns a Double !
You should use NumberFormat to display numbers with the given format, NumberFormat returns a String. This has nothing to with calculations !