For Java:
public static String humanReadableByteCount(Long bytes,boolean si){
int unit=si?1000:1024;
if(bytes<unit){
return bytes+" B";
}
int exp=(int)(Math.log(bytes)/Math.log(unit));
return String.format("%.1f %sB",bytes/Math.pow(unit,exp),(si?"kMGTPE":"KMGTPE").charAt(exp-1)+(si?"":"i"));
}
From Here
For JavaScript:
function humanReadableByteCount(bytes,si){
var unit=si?1000:1024;
if(bytes<unit){
return bytes+" B";
}
var exp=Math.floor(Math.log(bytes)/Math.log(unit));
return (bytes/Math.pow(unit,exp))+" "+(si?"kMGTPE":"KMGTPE").charAt(exp-1)+(si?"":"i")+"B";
}
Monday, August 15, 2016
Tuesday, January 26, 2016
Java vs python
Java versus Python
I have seen this on Facebook.
First read this.
Language Wars
Technically speaking the two programs aren't the same.
Both programs will give a different output.
The python has no output when executed.
The Java program outputs is this:
*
**
***
****
*****
So I guess you get more done with Java, because python does nothing.
Sunday, January 24, 2016
Language Wars
What ever happened to the time when people just wanted to learn languages rather than bitching about them?
There are pros and cons with all languages.
That is why there are so many languages.
There is no golden star programming language.
Each language has a goal of solving a problem that other languages don't solve.
Many be you should stop fighting, and go back to learning new languages and programming in them.
There are pros and cons with all languages.
That is why there are so many languages.
There is no golden star programming language.
Each language has a goal of solving a problem that other languages don't solve.
Many be you should stop fighting, and go back to learning new languages and programming in them.
Subscribe to:
Comments (Atom)