Numeric.isLong
check if the value stored in the Numeric fits into a Java long
Calling Sequence
Description
Examples
boolean isLong() throws MapleException
The isLong function returns true if the value represented by the current Numeric object is an integer small enough to fit into a Java long. Otherwise, the isLong function returns false.
If isLong returns true, a call to longValue completes without error.
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.isLong() );
try
n.longValue();
}
catch ( MapleException me )
System.out.println( me.getMessage() );
n = (Numeric)engine.evaluate( "2^60:" );
long l = n.longValue();
System.out.println( l );
Executing this code produces the following output.
false
Error, value too large for integer[8]
true
1152921504606846976
See Also
ExternalCalling/Java/MapleException
OpenMaple
OpenMaple/Java/API
OpenMaple/Java/Numeric
OpenMaple/Java/Numeric/isByte
OpenMaple/Java/Numeric/isInt
OpenMaple/Java/Numeric/isInteger
OpenMaple/Java/Numeric/isShort
OpenMaple/Java/Numeric/longValue
Download Help Document