Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getReadableHashrateString #110

Open
CerveloFellow opened this issue Mar 10, 2018 · 0 comments
Open

getReadableHashrateString #110

CerveloFellow opened this issue Mar 10, 2018 · 0 comments

Comments

@CerveloFellow
Copy link

On my admin userlist page, the readable hashrate was showing all of the array indices with the existing algorithm. So for example 1.24 KH/s would display as 1.24 h/s Kh/s Mh/s Gh/s Th/s Ph/s

I changed the function in api.js to this and got better results.

I'm not real familiar with git, otherwise I would have done a pull request with these changes.

function getReadableHashRateString(hashrate){
var displayrate = ["", "k", "M", "G", "T", "P"];
if(hashRate == 0) return '0 ';
var k = 1024,
i = Math.floor(Math.log(hashRate) / Math.log(k));
return parseFloat((hashRate/ Math.pow(k, i)).toFixed(2)) + ' ' + displayrate[i];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant