Numeric.isLong - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : OpenMaple : Java Application Programming Interface : Numeric Class : OpenMaple/Java/Numeric/isLong

Numeric.isLong

check if the value stored in the Numeric fits into a Java long

 

Calling Sequence

Description

Examples

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

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

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam