1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.components.browser_ui.util;
6 
7 /**
8  * A class containing some utility static methods for common conversions.
9  */
10 public class ConversionUtils {
11     public static final int BYTES_PER_KILOBYTE = 1024;
12     public static final int BYTES_PER_MEGABYTE = 1024 * 1024;
13     public static final int BYTES_PER_GIGABYTE = 1024 * 1024 * 1024;
14     public static final int KILOBYTES_PER_MEGABYTE = 1024;
15     public static final int KILOBYTES_PER_GIGABYTE = 1024 * 1024;
16 
bytesToKilobytes(long bytes)17     public static long bytesToKilobytes(long bytes) {
18         return bytes / BYTES_PER_KILOBYTE;
19     }
20 
bytesToMegabytes(long bytes)21     public static long bytesToMegabytes(long bytes) {
22         return bytes / BYTES_PER_MEGABYTE;
23     }
24 
bytesToGigabytes(long bytes)25     public static long bytesToGigabytes(long bytes) {
26         return bytes / BYTES_PER_GIGABYTE;
27     }
28 
kilobytesToMegabytes(long kilobytes)29     public static long kilobytesToMegabytes(long kilobytes) {
30         return kilobytes / KILOBYTES_PER_MEGABYTE;
31     }
32 }
33