Java Code Examples for org.bitcoinj.utils.Fiat#subtract()
The following examples show how to use
org.bitcoinj.utils.Fiat#subtract() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GaService.java From GreenBits with GNU General Public License v3.0 | 5 votes |
public String coinToFiat(final Coin btcValue) { if (!hasFiatRate()) return "N/A"; Fiat fiatValue = getFiatRate().coinToFiat(btcValue); // strip extra decimals (over 2 places) because that's what the old JS client does fiatValue = fiatValue.subtract(fiatValue.divideAndRemainder((long) Math.pow(10, Fiat.SMALLEST_UNIT_EXPONENT - 2))[1]); return MonetaryFormat.FIAT.minDecimals(2).noCode().format(fiatValue).toString(); }
Example 2
Source File: Exchanger.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private double convertBtcToFiat(final Coin btcValue) { try { Fiat fiatValue = mService.getFiatRate().coinToFiat(btcValue); // strip extra decimals (over 2 places) because that's what the old JS client does fiatValue = fiatValue.subtract(fiatValue.divideAndRemainder((long) Math.pow(10, Fiat.SMALLEST_UNIT_EXPONENT - 2))[1]); return Double.valueOf(fiatValue.toPlainString()); } catch (final ArithmeticException | IllegalArgumentException e) { return -1; } }