Lello1964 Well-Known Member Licensed User Longtime User Jun 16, 2021 #1 I have foud this difference between Android 9 and Android 11 I have this code B4X: Dim a As Int =0 Log(NumberFormat(a,0,4) ) Android 9 : result = 0 Android 11 : result = .0 why there is . before 0 ? Someone have some problem, how solve ? other example B4X: Dim a As Int =12 Log(NumberFormat(a,0,4) ) Android 9 : result = 12 Android 11 : result = 12.0 Last edited: Jun 16, 2021
I have foud this difference between Android 9 and Android 11 I have this code B4X: Dim a As Int =0 Log(NumberFormat(a,0,4) ) Android 9 : result = 0 Android 11 : result = .0 why there is . before 0 ? Someone have some problem, how solve ? other example B4X: Dim a As Int =12 Log(NumberFormat(a,0,4) ) Android 9 : result = 12 Android 11 : result = 12.0
Lello1964 Well-Known Member Licensed User Longtime User Jun 16, 2021 #2 NumberFormat2 have some problem Upvote 0
D Deleted member 103 Guest Jun 16, 2021 #4 Lello1964 said: I have foud this difference between Android 9 and Android 11 I have this code B4X: Dim a As Int =0 Log(NumberFormat(a,0,4) ) Android 9 : result = 0 Android 11 : result = .0 why there is . before 0 ? Someone have some problem, how solve ? other example B4X: Dim a As Int =12 Log(NumberFormat(a,0,4) ) Android 9 : result = 12 Android 11 : result = 12.0 Click to expand... I also have this mistake in earlier versions when I remember correctly. Upvote 0
Lello1964 said: I have foud this difference between Android 9 and Android 11 I have this code B4X: Dim a As Int =0 Log(NumberFormat(a,0,4) ) Android 9 : result = 0 Android 11 : result = .0 why there is . before 0 ? Someone have some problem, how solve ? other example B4X: Dim a As Int =12 Log(NumberFormat(a,0,4) ) Android 9 : result = 12 Android 11 : result = 12.0 Click to expand... I also have this mistake in earlier versions when I remember correctly.
Peter Simpson Expert Licensed User Longtime User Jun 16, 2021 #5 Log(NumberFormat(a, 0, 0)) Log(NumberFormat2(a, 0, 0, 0, False)) Upvote 0
Lello1964 Well-Known Member Licensed User Longtime User Jun 16, 2021 #6 Peter Simpson said: Log(NumberFormat(a, 0, 0)) Log(NumberFormat2(a, 0, 0, 0, False)) Click to expand... isn't a solution but if i have 12.546 result is 12 but it must be 12.546 Upvote 0
Peter Simpson said: Log(NumberFormat(a, 0, 0)) Log(NumberFormat2(a, 0, 0, 0, False)) Click to expand... isn't a solution but if i have 12.546 result is 12 but it must be 12.546
Peter Simpson Expert Licensed User Longtime User Jun 16, 2021 #7 Lello1964 said: isn't a solution but if i have 12.546 result is 12 but it must be 12.546 Click to expand... What, 12.546 is a decimal and not an integer, what are you talking about??????? Make your mind up will you, you wrote Code: Dim a As Int =12 Can you see where you wrote Int, how are you seriously expecting to get 12.546 ??? Upvote 0
Lello1964 said: isn't a solution but if i have 12.546 result is 12 but it must be 12.546 Click to expand... What, 12.546 is a decimal and not an integer, what are you talking about??????? Make your mind up will you, you wrote Code: Dim a As Int =12 Can you see where you wrote Int, how are you seriously expecting to get 12.546 ???
Lello1964 Well-Known Member Licensed User Longtime User Jun 16, 2021 #8 sorry. but the problem isn't solved Dim b As Double =12.546 Log(NumberFormat(b,0,0)) Log(NumberFormat2(b,0,0,0,True)) result : 12 13 doesn't solve my problem. Upvote 0
sorry. but the problem isn't solved Dim b As Double =12.546 Log(NumberFormat(b,0,0)) Log(NumberFormat2(b,0,0,0,True)) result : 12 13 doesn't solve my problem.
D DataMiser Member Licensed User Jun 16, 2021 #9 you are passing 0 for the min and max decimal places so of course you get nothing after the decimal. If you want a max of 3 decimal places then you need to place a 3 in that parameter. Upvote 0
you are passing 0 for the min and max decimal places so of course you get nothing after the decimal. If you want a max of 3 decimal places then you need to place a 3 in that parameter.
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2021 #10 Please use [code]code here...[/code] tags when posting code. I don't see any unexpected result in this thread. I think that tou are looking for: Code: NumberFormat2(b,1,3,0,True) Upvote 0
Please use [code]code here...[/code] tags when posting code. I don't see any unexpected result in this thread. I think that tou are looking for: Code: NumberFormat2(b,1,3,0,True)
Lello1964 Well-Known Member Licensed User Longtime User Jun 17, 2021 #11 Erel said: Please use [code]code here...[/code] tags when posting code. I don't see any unexpected result in this thread. I think that tou are looking for: Code: NumberFormat2(b,1,3,0,True) Click to expand... Why difference between Android <11 and android 11 result ? Upvote 0
Erel said: Please use [code]code here...[/code] tags when posting code. I don't see any unexpected result in this thread. I think that tou are looking for: Code: NumberFormat2(b,1,3,0,True) Click to expand... Why difference between Android <11 and android 11 result ?
Lello1964 Well-Known Member Licensed User Longtime User Jun 17, 2021 #12 B4X: Dim a As Int =0 Log(NumberFormat(a,0,4)) result : in Andoid9 : 0 in Android10 : .0 This isn't same. Upvote 0
B4X: Dim a As Int =0 Log(NumberFormat(a,0,4)) result : in Andoid9 : 0 in Android10 : .0 This isn't same.
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2021 #13 Why are you setting the minimum integers parameter to 0? If you want it to be 1 then set it to 1. It is really simple. The results meet your settings. Upvote 0
Why are you setting the minimum integers parameter to 0? If you want it to be 1 then set it to 1. It is really simple. The results meet your settings.
Lello1964 Well-Known Member Licensed User Longtime User Jun 17, 2021 #14 This is only an example Erel said: Why are you setting the minimum integers parameter to 0? If you want it to be 1 then set it to 1. It is really simple. The results meet your settings. Click to expand... this is just one example. The difference also occurs with other numbers and formats. Having to convert the numeric format into Italian, this generates errors in the app. changing the function in NumberFormat2 all the representations of the numbers change, compromising the graphic result. Upvote 0
This is only an example Erel said: Why are you setting the minimum integers parameter to 0? If you want it to be 1 then set it to 1. It is really simple. The results meet your settings. Click to expand... this is just one example. The difference also occurs with other numbers and formats. Having to convert the numeric format into Italian, this generates errors in the app. changing the function in NumberFormat2 all the representations of the numbers change, compromising the graphic result.
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2021 #15 Lello1964 said: this is just one example. Click to expand... This is the only example you posted and it is wrong. If you have other examples then post them. Upvote 0
Lello1964 said: this is just one example. Click to expand... This is the only example you posted and it is wrong. If you have other examples then post them.
Lello1964 Well-Known Member Licensed User Longtime User Jun 17, 2021 #16 @Star-Dust tell me a solution. But i must rmodify all my Apps. B4X: Public Sub NumberFormatPlus(Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String If Number=Round(Number) Then Return $"$1.0{Number}"$ Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If End Sub Upvote 0
@Star-Dust tell me a solution. But i must rmodify all my Apps. B4X: Public Sub NumberFormatPlus(Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String If Number=Round(Number) Then Return $"$1.0{Number}"$ Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If End Sub
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2021 #17 It is equivalent to: Code: If Number=Round(Number) Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If I don't know what you are trying to do but will probably be safer to do something like: Code: If Abs(Number - Round(Number)) < 0.00000001 Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If Upvote 0
It is equivalent to: Code: If Number=Round(Number) Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If I don't know what you are trying to do but will probably be safer to do something like: Code: If Abs(Number - Round(Number)) < 0.00000001 Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If
Lello1964 Well-Known Member Licensed User Longtime User Jun 17, 2021 #18 Erel said: It is equivalent to: Code: If Number=Round(Number) Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If I don't know what you are trying to do but will probably be safer to do something like: Code: If Abs(Number - Round(Number)) < 0.00000001 Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If Click to expand... Thanks @Erel, i'll use your solution, but why this difference between Andorid 9 and Android 11? Upvote 0
Erel said: It is equivalent to: Code: If Number=Round(Number) Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If I don't know what you are trying to do but will probably be safer to do something like: Code: If Abs(Number - Round(Number)) < 0.00000001 Then Return NumberFormat(Number, 1, 0) Else Return NumberFormat(Number,MinimumIntegers,MaximumFractions) End If Click to expand... Thanks @Erel, i'll use your solution, but why this difference between Andorid 9 and Android 11?
Star-Dust Expert Licensed User Longtime User Jun 17, 2021 #19 Would solve the problem by simply setting the number of digits of integers to 1 rather than 0. Setting it to 0 Android 11 when there are no integers does not even display zero, and it seems to me a correct behavior while previous versions when there are no digits integers displays zero Upvote 0
Would solve the problem by simply setting the number of digits of integers to 1 rather than 0. Setting it to 0 Android 11 when there are no integers does not even display zero, and it seems to me a correct behavior while previous versions when there are no digits integers displays zero
Star-Dust Expert Licensed User Longtime User Jun 17, 2021 #20 Or Alternative B4X: Public Sub NumberFormatPlus(Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String Return NumberFormat(Number,Max(MinimumIntegers,1),MaximumFractions) End Sub Last edited: Jun 18, 2021 Upvote 0
Or Alternative B4X: Public Sub NumberFormatPlus(Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String Return NumberFormat(Number,Max(MinimumIntegers,1),MaximumFractions) End Sub