Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions www/lendingbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ function updateOutputCurrency(outputCurrency){
// below zero accuracy will indicate precision after must significat digit
// strips trailing zeros
function prettyFloat(value, accuracy) {
var precision = Math.round(Math.log10(value));
precision = precision < 0 ? Math.abs(precision) + accuracy : accuracy;
var multiplier = Math.pow(10, precision);
var result = Math.round(value * multiplier) / multiplier;
return isNaN(result) ? "0" : parseFloat(result.toFixed(precision));
var precision = Math.round(Math.log10(value));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rnevet it would be great to keep same indention style in JS code (rest of the code uses 4 spaces).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are ofc correct

var result = precision < 0 ? value.toFixed(Math.min((accuracy - precision), 8)) : value.toFixed(accuracy);
return isNaN(result) ? "0" : result.replace(/(?:\.0+|(\.\d+?)0+)$/, "$1");
}

function printFloat(value, precision) {
Expand Down