Numeric.toBigDecimal
return the value of the Numeric object as a Java BigDecimal
Calling Sequence
Description
Examples
Compatibility
java.math.BigDecimal toBigDecimal() throws MapleException
The toBigDecimal function returns the value represented in the Numeric as a Java BigDecimal.
The java.math.BigDecimal format can represent arbitrary-precision floating-point numbers, but not NaN or infinite quantities. If the value is NaN or infinite, an error is raised.
import java.math.BigDecimal;
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( "evalf[60](Pi):" );
System.out.println( n );
BigDecimal bd = n.toBigDecimal();
System.out.println( bd );
}
Executing this code produces the following output.
3.14159265358979323846264338327950288419716939937510582097494
The Numeric.toBigDecimal 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/toBigInteger
Download Help Document