Java-math-biginteger-not
提供:Dev Guides
Java.math.BigInteger.not()メソッド
説明
- java.math.BigInteger.not()*は、値が(〜this)のBigIntegerを返します。 このBigIntegerが負でない場合にのみ、このメソッドは負の値を返します。
宣言
以下は* java.math.BigInteger.not()*メソッドの宣言です。
public BigInteger not()
パラメーター
NA
戻り値
このメソッドは、値が〜thisであるBigIntegerオブジェクトを返します。
例外
NA
例
次の例は、math.BigInteger.not()メソッドの使用方法を示しています。
package com.finddevguides;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
//create 4 BigInteger objects
BigInteger bi1, bi2, bi3, bi4;
//assign values to bi1, bi2
bi1 = new BigInteger("6");
bi2 = new BigInteger("-6");
//perform not operation on bi1 and bi2
bi3 = bi1.not();
bi4 = bi2.not();
String str1 = "Result of not operation on " + bi1 +" gives " +bi3;
String str2 = "Result of not operation on " + bi2 +" gives " +bi4;
//print bi3, bi4 values
System.out.println( str1 );
System.out.println( str2 );
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
Result of not operation on 6 gives -7
Result of not operation on -6 gives 5