B4i Library [class] DecimalNumber (similar to B4A BigNumber)

Erel

Administrator
Staff member
Licensed User
This class uses NativeObject to access NSDecimalNumber type. Unlike BigNumber library, the objects are immutable. This means that the value of a DecimalNumber instance cannot change. A new value can be assigned.

Usage example:
B4X:
Dim dm1 As DecimalNumber = CreateDecimal("123.11111111111111111111")
Log(dm1.Add(CreateDecimal("0.22222222222222222222")).ToString)
Log(CreateDecimal(2).Multiply(CreateDecimal(10)).ToString)
Log(CreateDecimal(100).Divide(CreateDecimal(10)).Subtract(CreateDecimal(5)).ToString)

Sub CreateDecimal(Value As String) As DecimalNumber
   Dim dm As DecimalNumber
   dm.Initialize(Value)
   Return dm
End Sub
 

Attachments

Top