isLong - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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 = { "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:" );

        System.out.println( n.isLong() );

        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