Edited 09042025:
This is not a good solution. read the whole tread
********************************************************************************************************
Maybe someone think this is useful
This is not a good solution. read the whole tread
********************************************************************************************************
Maybe someone think this is useful
B4X:
Sub NumberToEnotation(Value As Double, SignFigs As Int) As String
Dim DecPlaces As Int = SignFigs - 1
Dim isNeg As Boolean
Dim e As Int
Dim res As String
If Value < 0 Then
Value = Value * -1
isNeg = True
End If
If Value >= 1 Then
e = Floor(Logarithm(Value,10))
res = $"${NumberFormat2(Value/Power(10,e),1,DecPlaces,DecPlaces, False)}e+${e}"$
else if Value = 0 Then
res = NumberFormat2(0,1,DecPlaces,DecPlaces, False)
Else If Value < 1 Then
e = Ceil(Logarithm(1/Value,10))
res = $"${NumberFormat2(Value*Power(10,e),1,DecPlaces,DecPlaces, False)}E-${e}"$
End If
If isNeg Then res = "-" & res
Return res
End Sub
Last edited: