Numeric.toBigInteger
return the value of the Numeric object as a Java BigInteger
Calling Sequence
Description
Examples
Compatibility
java.math.BigInteger toBigInteger() throws MapleException
The toBigInteger function returns the value represented in the Numeric as a Java BigInteger.
The java.math.BigInteger format can represent arbitrary-precision integers. If the value is not an integer, an error is raised.
To determine if the value is an integer, use the isInteger function.
import java.math.BigInteger;
import com.maplesoft.openmaple.*;
import com.maplesoft.externalcall.MapleException;
class Example
{
public static void main( String notused[] ) throws MapleException
String[] mapleArgs = { "java" };
Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null );
Numeric n = (Numeric)engine.evaluate( "2^66:" );
System.out.println( n );
System.out.println( n.isLong() );
BigInteger bd = n.toBigInteger();
System.out.println( bd );
}
Executing this code produces the following output.
302231454903657293676544
false
The Numeric.toBigInteger command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
ExternalCalling/Java/MapleException
OpenMaple
OpenMaple/Java/API
OpenMaple/Java/Numeric
OpenMaple/Java/Numeric/byteValue
OpenMaple/Java/Numeric/doubleValue
OpenMaple/Java/Numeric/floatValue
OpenMaple/Java/Numeric/intValue
OpenMaple/Java/Numeric/isLong
OpenMaple/Java/Numeric/longValue
OpenMaple/Java/Numeric/shortValue
OpenMaple/Java/Numeric/toBigDecimal
Download Help Document