Code example for BigInteger

Methods: longValue

0
		 **************************************************************************/ 
		BigInteger num = BigInteger.valueOf(newBalance);
		BigInteger den = BigInteger.valueOf(Long.valueOf(100));
		BigInteger gcd = num.gcd(den);
 
		Long numerator = num.longValue() / gcd.longValue();
		Long denominator = den.longValue() / gcd.longValue();
		 
		return String.valueOf(numerator) + "/" + String.valueOf(denominator);
	} 
	 
	static public Long convertBalance(String fraction)
	{ 
		/*************************************************************************** 
		 * We take in the fraction string from the database and convert it to our 
		 * Long value of cents. 
		 **************************************************************************/ 
		String parts[] = fraction.split("/");
		Float num = Float.valueOf(parts[0]);
		Float den = Float.valueOf(parts[1]);
		Float value = (num / den) * 100;