Here you can find the source of convertMB2GB(int valueMB)
Officially, there are 1000 (10^3) megabytes (MB) in a gigabyte (GB)
A Memory manufacturer definition is 1024 (2^10) megabytes per gigabyte, but this is more properly called a gigabinary byte (GiB), sometimes contracted to gibibyte.
Parameter | Description |
---|---|
valueMB | a parameter |
public static double convertMB2GB(int valueMB)
//package com.java2s; /**// w w w . j a v a2 s.c o m * Copyright 2005-2015 titilink * * The contents of this file are subject to the terms of one of the following * open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL * 1.0 (the "Licenses"). You can select the license that you prefer but you may * not use this file except in compliance with one of these Licenses. * * You can obtain a copy of the Apache 2.0 license at * http://www.opensource.org/licenses/apache-2.0 * * You can obtain a copy of the LGPL 3.0 license at * http://www.opensource.org/licenses/lgpl-3.0 * * You can obtain a copy of the LGPL 2.1 license at * http://www.opensource.org/licenses/lgpl-2.1 * * You can obtain a copy of the CDDL 1.0 license at * http://www.opensource.org/licenses/cddl1 * * You can obtain a copy of the EPL 1.0 license at * http://www.opensource.org/licenses/eclipse-1.0 * * See the Licenses for the specific language governing permissions and * limitations under the Licenses. * * Alternatively, you can obtain a royalty free commercial license with less * limitations, transferable or non-transferable, directly at * https://github.com/titilink/titilink-framework * * titilink is a registered trademark of titilink.inc */ import java.math.BigDecimal; public class Main { /** * A normal decimal kilo is 1000 */ private static final BigDecimal DECIMAL_KILO = new BigDecimal("1000"); /** * Convert a decimal MB(megabyte) to decimal GB(gigabyte)<br> * <br> * <p> * Officially, there are <b>1000 (10^3)</b> megabytes (MB) in a gigabyte * (GB)<br> * A Memory manufacturer definition is <b>1024 (2^10)</b> megabytes per * gigabyte, but this is more properly called a <b>gigabinary byte * (GiB)</b>, sometimes contracted to <b>gibibyte</b>. <br> * <br> * 1,000 megabyte (MB) = 1 gigabyte (GB)<br> * 1,024 mebibyte (MiB) = 1 gibibyte (GiB)<br> * * @param valueMB * @return GB */ public static double convertMB2GB(int valueMB) { return (new BigDecimal(valueMB).divide(DECIMAL_KILO).doubleValue()); } }