ramin83karimi
Member
hi
i have written the following piece of code:
i used the "big numbers" library to get some accurate results
at the end the program logs pi squared, and i need to square-root it accurately, but with the core options in b4x i don't think that's possible.
i tried using the same "big numbers" library to do that but it seems that it doesn't have a sqrt function
i even tried using "pow" in that library which is the equivalent of power in core, i thought i could take it to the power of 0.5 which should be the equivalent of sqrt, but "pow" only accepts integers as an input and 0.5 is floating
.
any ideas what i should do?
i have written the following piece of code:
B4X:
Dim pi As BigDecimal
pi.Initialize(0)
Dim b As BigDecimal
Dim c As BigDecimal
c.Initialize(0)
b.Initialize(0)
Dim t As Long
t=DateTime.Now
For i=1 To 1000000
c.Initialize(i)
c.Multiply(c)
b.Initialize(1)
b.Divide2(c,100,0)
pi.Add(b)
Next
c.Initialize(6)
pi.Multiply(c)
Log(pi)
Log(DateTime.Now-t)
at the end the program logs pi squared, and i need to square-root it accurately, but with the core options in b4x i don't think that's possible.
i tried using the same "big numbers" library to do that but it seems that it doesn't have a sqrt function
i even tried using "pow" in that library which is the equivalent of power in core, i thought i could take it to the power of 0.5 which should be the equivalent of sqrt, but "pow" only accepts integers as an input and 0.5 is floating
.
any ideas what i should do?