jayel Active Member Licensed User Longtime User Mar 18, 2018 #1 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
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
K keirS Well-Known Member Licensed User Longtime User Mar 18, 2018 #2 Because it's using Round Half Even (Bankers Rounding) to round the numbers. Upvote 0
jayel Active Member Licensed User Longtime User Mar 18, 2018 #3 Ok. Can I get it to be 9 with another function? Upvote 0
K keirS Well-Known Member Licensed User Longtime User Mar 18, 2018 #5 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
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))
jayel Active Member Licensed User Longtime User Mar 18, 2018 #6 hmmm, where did you get the bigdecimal? My variable is a double Upvote 0
K keirS Well-Known Member Licensed User Longtime User Mar 18, 2018 #7 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
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