Better HN
topnewbestaskshowjobs
Log inSign up

chriscosma

2 karma · joined Sep 23, 2023 (3y ago) · 2 submissions

Submissions

comment 3y ago · link · parent

OP has already worked at both Facebook and Google, it's doubtful they need any more resume-bolstering.

comment 3y ago · link · parent

GPT-3.5 returns:

    public static String convertBytes(long bytes) {
        String[] suffixes = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
        if (bytes < 1024) return bytes + " " + suffixes[0];
        int exp = (int) (Math.log(bytes) / Math.log(1024));
        return String.format("%.2f %s", bytes / Math.pow(1024, exp), suffixes[exp]);
    }