Android Question Big Decimal Conversion

WDK

Member
Licensed User
I am trying to do a calculation with Big Decimal. I am getting an error stating that I can't have double variables in my formula. Do all variables in a Big Decimal calculation need to be Big Decimal?

Also, how do I convert text to Big Decimal?

ie.

BigDecimalNumber = EditText.text

Thanks for any help!
WDK
 

Attachments

  • Image 2.png
    Image 2.png
    12.8 KB · Views: 300

OliverA

Expert
Licensed User
Longtime User
If you look at the provided XML file for the library, you'll find several Initialize routines. The first one (Initialize) will take a string and convert it to a Big Decimal object.

Therefore instead of
B4X:
BigDecimalNumber = EditText.text
it should be
B4X:
BigDecimalNumber.Initialize(EditText.text)
Please note that all operations (division, multiplication, addition, subtraction) must be done using the provided methods of the class instead of
B4X:
CalculateFormula = FormulaFrom * FormulaTo * Ed
it would be
B4X:
CalculateFormula.Initialize5(FormulaFrom.Multiply(FormulaTo.Multiply(Ed)))
Where CalculateFormula, FormulaFrom, FormulaTo and Ed have all been Dim'd as the proper big decimal type

Note: Code has not been validated. I'm just going off of what I found in the XML file and therefore may be way off base. This is just a more expanded answer to @sorex's hint.

Ninja'd as usual....
 
Upvote 0

WDK

Member
Licensed User
Oliver,

Thanks for the detailed information. That is really helpful and explains everything I am trying to accomplish.

Much appreciated!

WDK
 
Upvote 0
Top