Skip to content

Instantly share code, notes, and snippets.

@tral
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tral/6048ceebf906edc0b44f to your computer and use it in GitHub Desktop.
Save tral/6048ceebf906edc0b44f to your computer and use it in GitHub Desktop.
alg
// Баланс пользователя в Rch
Double userBalanceRch = Double.parseDouble(User.getBalanceRch(activity));
// Шаг вывода в валюте продавца, если не задан, берем 1
Double outStep = 1.0;
try {
outStep = Double.parseDouble(f_out_step);
} catch (Exception e) {
}
// Минимально возможный вывод в Rch, если не задан, то 0
Double minPossibleOutRch = 0.0;
try {
minPossibleOutRch = Double.parseDouble(f_min_out);
} catch (Exception e) {
}
// Курс обмена, если не задан, то 1
Double rateMerchant = 1.0;
try {
rateMerchant = Double.parseDouble(f_currency_rate);
} catch (Exception e) {
}
// Максимально возможный вывод в валюте продавца
// Вообще, максимально 8000 Rch можно выводить
userBalanceRch = (userBalanceRch > 8000) ? 8000 : userBalanceRch;
Double maxPossibleOut = userBalanceRch * rateMerchant;
maxPossibleOut = (Math.floor(maxPossibleOut / outStep)) * outStep;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment