Android Question Extend number length in AHNumeric.Format (Double)

LGS

Member
Licensed User
Longtime User
Hello everyone.

Format in the AHNumeric object, receives a value of type Double (~ 15 digits)

Code:
...
Dim data As String
    data = "9999999999999.99"      
    Log(nf.Format(data))                   'RESULT:       9.999.999.999.999,99 OK
    data = "99999999999999.99"     
    Log(nf.Format(data))                   'RESULT:      99.999.999.999.999,98 formatted and modified
    data = "999999999999999.99"    
    Log(nf.Format(data))                   'RESULT:   1.000.000.000.000.000 formatted and rounded
    data = "899999999999999999.99" 
    Log(nf.Format(data))                   'RESULT: 900.000.000.000.000.000 formatted and rounded
...

Sub SetFormatChars(Grouping As Char, DecimalSeparator As Char) As AHNumeric
    Dim loc As AHLocale
    loc.InitializeUS
    Dim jloc As JavaObject = loc
    jloc = jloc.GetField("myLocale")
    Dim nfs As AHNumeric
    nfs.InitializeNumber2(loc)
    Dim r As Reflector
    r.Target = nfs
    Dim dfs As JavaObject
    dfs.InitializeNewInstance("java.text.DecimalFormatSymbols", Array(jloc))
    dfs.RunMethod("setGroupingSeparator", Array(Grouping))
    dfs.RunMethod("setDecimalSeparator", Array(DecimalSeparator))
    Dim jo As JavaObject = r.GetField("mNumberFormat")
    jo.RunMethod("setDecimalFormatSymbols", Array(dfs))
    Return nfs
End Sub

When the formatted number is greater than 15 digits, it is rounded (modified)

Is there a way to use this function with numbers of 18 or more digits?

Thanks in advance...
 

Attachments

  • Double.png
    Double.png
    4.6 KB · Views: 153
  • Decimal.zip
    10.1 KB · Views: 165

agraham

Expert
Licensed User
Longtime User
Upvote 0

LGS

Member
Licensed User
Longtime User
Agraham, thank you for your support.

I really only need to format 2 decimal places and AHNumeric.Format does it when the number to be formatted is 15 digits
I would like to use AHNumeric.Format but with a greater length number (example 18 digits) and the formatted result not rounded

Thanks again for your time
 
Upvote 0

LGS

Member
Licensed User
Longtime User
Ok.
I will have to find another way to format numbers with lengths greater than 15

Thank you
 
Upvote 0
Top