I NEED to send the value as " double ", but I:
- Assuming the value long
- Convert it to BigDecimal
- The method to call scaleByPowerOfTen in BigDecimal (using "-2" to make cents an integer).
- Call doubleValue () in BigDecimal to get the required value as double .
Now I know that double values lose accuracy when applying arithmetic operations to them , but what can I get if I try to send a double as-is value based on BigDecimal, for example (I suppose) the above script.
This is important because I have to send monetary values via SOAP this way - there is no other way.
I also have a script in which a BigDecimal is created using String , then doubleValue () is called on it . What can I get in this case?
EDIT: Sample code for this:
long amountInCents = 1852;
BigDecimal amountInWholeUnits = BigDecimal.valueOf(amountInCents).scaleByPowerOfTen(-2);
double amountToSend = amountInWholeUnits.doubleValue();
As for the case when the amount is provided as a string:
double amountToSend = new BigDecimal("18.52").doubleValue();
UPDATE
, , , , System.out.println: , , , SOAP. , , .