0

I am making a request to my local server and getting the following numbers in my response:

<PercentSm>2.40</PercentSm>
<FlatSm>0.00</FlatSm>
<MaxSm>99999999.00</MaxSm>
<FlatLgs>0.20</FlatLgs>

when i save them as Double or Float android rounds them down to one decimal place and the MaxSm field is diplayed as 9.9999999E7.

I want to be able to store them with the exact same value and decimal point like i get them. I tries using DecimalFormat but it only supports API 24 and higher. Is there any other way of doing this that will support older apis as well? for example API 19 and up?

pavlos
  • 547
  • 1
  • 9
  • 23

1 Answers1

0

use NumberFormat

this class can format your numbers for you.NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers. NumberFormat also provides methods for determining which locales have number formats, and what their names are. digits used, or whether the number format is even decimal.

You can also use,Formatted printing, With the Formatter Class then parse the results with Integer.parseInt() though this is more less efficient.

Remario
  • 3,813
  • 2
  • 18
  • 25