Numeric.isLong - check if the value stored in the Numeric fits into a Java long
|
Calling Sequence
|
|
boolean isLong() throws MapleException
|
|
Description
|
|
•
|
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.
|
|
|
Examples
|
|
import com.maplesoft.openmaple.*;
|
import com.maplesoft.externalcall.MapleException;
|
class Example
|
{
|
public static void main( String notused[] ) throws MapleException
|
{
|
String mapleArgs[];
|
Engine engine;
|
Numeric n;
|
long l;
|
mapleArgs = new String[1];
|
mapleArgs[0] = "java";
|
engine = new Engine( mapleArgs, new EngineCallBacksDefault(),
|
null, null );
|
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:" );
|
System.out.println( n.isLong() );
|
l = n.longValue();
|
System.out.println( l );
|
}
|
}
|
|
|
Executing this code produces the following output.
false
|
Error, value too large for integer[8]
|
true
|
1152921504606846976
|
|
|
|
|
Download Help Document
Was this information helpful?