B4J Question [SOLVED] Numberformat

jayel

Active Member
Licensed User
Longtime User
hello,

Why is this both 10?

B4X:
Dim mdouble As Double = 10.5
Log (NumberFormat2(mdouble,2,0,0,False))

B4X:
Dim mdouble As Double = 9.5
Log (NumberFormat2(mdouble,2,0,0,False))

I want the second one to be 9 !

John
 

keirS

Well-Known Member
Licensed User
Longtime User
Sorry I cut and pasted the wrong bit of code which is why I deleted the message.

B4X:
Dim abc As BigDecimal
abc.Initialize("9.5")
Log(abc.Round(1,abc.ROUND_HALF_DOWN))
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
Does't matter.

B4X:
    Dim mDouble As Double = 9.5
    Dim abc As BigDecimal
    abc.Initialize(mDouble)
    Log(abc.Round(1,abc.ROUND_DOWN))

Still works.

The BigDecimal is from the BigNumbers library
 
Upvote 0
Top