List of usage examples for java.math BigInteger BigInteger
private BigInteger(long val)
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("8");// 1000 BigInteger bi2 = new BigInteger("7");// 0111 // perform getLowestSetBit on bi1, bi2 int i1 = bi1.getLowestSetBit(); int i2 = bi2.getLowestSetBit(); System.out.println(i1);/*from w w w . j a va 2s. com*/ System.out.println(i2); }
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("7"); BigInteger bi2 = new BigInteger("-7"); // perform bitlength operation on bi1, bi2 int i1 = bi1.bitLength(); int i2 = bi2.bitLength(); System.out.println(i1);//w w w . j a v a 2s.c o m System.out.println(i2); }
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("7"); BigInteger bi2 = new BigInteger("-7"); // perform bitcount operation on bi1, bi2 int i1 = bi1.bitCount(); int i2 = bi2.bitCount(); System.out.println(i1);// www .j a va2 s. co m System.out.println(i2); }
From source file:Main.java
public static void main(String[] args) { BigInteger number = new BigInteger("2008"); System.out.println("Number = " + number); System.out.println("Binary = " + number.toString(2)); System.out.println("Octal = " + number.toString(8)); System.out.println("Hexadecimal = " + number.toString(16)); number = new BigInteger("FF", 16); System.out.println("Number = " + number); System.out.println("Number = " + number.toString(16)); }
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("-123"); BigInteger bi2 = new BigInteger("987654321"); // assign the long values of bi1, bi2 to l1, l2 Long l1 = bi1.longValue();/*from w w w . ja v a 2s . c om*/ Long l2 = bi2.longValue(); System.out.println(l1); System.out.println(l2); }
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("123"); BigInteger bi2 = new BigInteger("-123"); // assign absolute values of bi1, bi2 to bi3, bi4 BigInteger bi3 = bi1.abs();/* w w w. j a va 2 s . c o m*/ BigInteger bi4 = bi2.abs(); System.out.println(bi3); System.out.println(bi4); }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigInteger bi = new BigInteger("1023"); // Parse and format to binary bi = new BigInteger("1111111111", 2); String s = bi.toString(2);//from www . j a v a2s . c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigInteger bi1 = new BigInteger("1234567890123456890"); bi1 = bi1.negate();// w ww . j av a2s . co m }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigInteger bi1 = new BigInteger("1234567890123456890"); int exponent = 2; bi1 = bi1.pow(exponent);// ww w . j a v a 2s . c o m }
From source file:Main.java
public static void main(String[] args) { BigInteger bi1 = new BigInteger("123"); BigInteger bi2 = new BigInteger("123"); // compare bi1 with bi2 Boolean b1 = bi1.equals(bi2); // compare bi1 with an object value 123, which is not a BigIntger Boolean b2 = bi1.equals("123"); System.out.println(b1);/* w w w . j a v a 2 s .c o m*/ System.out.println(b2); }