Share via


BigDecimal Constructors

Definition

Overloads

BigDecimal(BigInteger)

Translates a BigInteger into a BigDecimal.

BigDecimal(Char[], Int32, Int32, MathContext)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified and with rounding according to the context settings.

BigDecimal(Char[], Int32, Int32)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified.

BigDecimal(BigInteger, Int32, MathContext)

Translates a BigInteger unscaled value and an int scale into a BigDecimal, with rounding according to the context settings.

BigDecimal(String, MathContext)

Translates the string representation of a BigDecimal into a BigDecimal, accepting the same strings as the #BigDecimal(String) constructor, with rounding according to the context settings.

BigDecimal(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

BigDecimal(Int64, MathContext)

Translates a long into a BigDecimal, with rounding according to the context settings.

BigDecimal(Double, MathContext)

Translates a double into a BigDecimal, with rounding according to the context settings.

BigDecimal(Int32, MathContext)

Translates an int into a BigDecimal, with rounding according to the context settings.

BigDecimal(BigInteger, Int32)

Translates a BigInteger unscaled value and an int scale into a BigDecimal.

BigDecimal(BigInteger, MathContext)

Translates a BigInteger into a BigDecimal rounding according to the context settings.

BigDecimal(String)

Translates the string representation of a BigDecimal into a BigDecimal.

BigDecimal(Int64)

Translates a long into a BigDecimal.

BigDecimal(Int32)

Translates an int into a BigDecimal.

BigDecimal(Double)

Translates a double into a BigDecimal which is the exact decimal representation of the double's binary floating-point value.

BigDecimal(Char[])

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor.

BigDecimal(Char[], MathContext)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor and with rounding according to the context settings.

BigDecimal(BigInteger)

Translates a BigInteger into a BigDecimal.

[Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;)V", "")]
public BigDecimal (Java.Math.BigInteger? val);
[<Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;)V", "")>]
new Java.Math.BigDecimal : Java.Math.BigInteger -> Java.Math.BigDecimal

Parameters

val
BigInteger

BigInteger value to be converted to BigDecimal.

Attributes

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.math.BigInteger).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Char[], Int32, Int32, MathContext)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified and with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "([CIILjava/math/MathContext;)V", "")]
public BigDecimal (char[]? in, int offset, int len, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "([CIILjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : char[] * int * int * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

in
Char[]

char array that is the source of characters.

offset
Int32

first character in the array to inspect.

len
Int32

number of characters to consider.

mc
MathContext

the context to use.

Attributes

Exceptions

if offset = in.length, or if in does not contain a valid string representation of a big decimal.

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(char[], int, int, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Char[], Int32, Int32)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified.

[Android.Runtime.Register(".ctor", "([CII)V", "")]
public BigDecimal (char[]? in, int offset, int len);
[<Android.Runtime.Register(".ctor", "([CII)V", "")>]
new Java.Math.BigDecimal : char[] * int * int -> Java.Math.BigDecimal

Parameters

in
Char[]

char array that is the source of characters.

offset
Int32

first character in the array to inspect.

len
Int32

number of characters to consider.

Attributes

Exceptions

if offset = in.length, or if in does not contain a valid string representation of a big decimal.

Remarks

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified.

Added in 1.5.

Java documentation for java.math.BigDecimal.BigDecimal(.*char[], .*int, .*int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(BigInteger, Int32, MathContext)

Translates a BigInteger unscaled value and an int scale into a BigDecimal, with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;ILjava/math/MathContext;)V", "")]
public BigDecimal (Java.Math.BigInteger? unscaledVal, int scale, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;ILjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : Java.Math.BigInteger * int * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

unscaledVal
BigInteger

unscaled value of the BigDecimal.

scale
Int32

scale of the BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

if unscaledVal == null.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.math.BigInteger, int, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(String, MathContext)

Translates the string representation of a BigDecimal into a BigDecimal, accepting the same strings as the #BigDecimal(String) constructor, with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/math/MathContext;)V", "")]
public BigDecimal (string? val, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : string * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

val
String

string representation of a BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if val does not contain a valid string representation of a big decimal.

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.lang.String, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected BigDecimal (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Java.Math.BigDecimal : nativeint * Android.Runtime.JniHandleOwnership -> Java.Math.BigDecimal

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Int64, MathContext)

Translates a long into a BigDecimal, with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(JLjava/math/MathContext;)V", "")]
public BigDecimal (long val, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(JLjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : int64 * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

val
Int64

long value to be converted to BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(long, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Double, MathContext)

Translates a double into a BigDecimal, with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(DLjava/math/MathContext;)V", "")]
public BigDecimal (double val, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(DLjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : double * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

val
Double

double value to be converted to BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if val is infinity or not a number.

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(double, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Int32, MathContext)

Translates an int into a BigDecimal, with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(ILjava/math/MathContext;)V", "")]
public BigDecimal (int val, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(ILjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : int * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

val
Int32

int value to be converted to BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if mc.precision > 0 and c.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(int, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(BigInteger, Int32)

Translates a BigInteger unscaled value and an int scale into a BigDecimal.

[Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;I)V", "")]
public BigDecimal (Java.Math.BigInteger? unscaledVal, int scale);
[<Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;I)V", "")>]
new Java.Math.BigDecimal : Java.Math.BigInteger * int -> Java.Math.BigDecimal

Parameters

unscaledVal
BigInteger

unscaled value of the BigDecimal.

scale
Int32

scale of the BigDecimal.

Attributes

Exceptions

if unscaledVal == null.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.math.BigInteger, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(BigInteger, MathContext)

Translates a BigInteger into a BigDecimal rounding according to the context settings.

[Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;Ljava/math/MathContext;)V", "")]
public BigDecimal (Java.Math.BigInteger? val, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "(Ljava/math/BigInteger;Ljava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : Java.Math.BigInteger * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

val
BigInteger

BigInteger value to be converted to BigDecimal.

mc
MathContext

the context to use.

Attributes

Exceptions

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.math.BigInteger, java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(String)

Translates the string representation of a BigDecimal into a BigDecimal.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")]
public BigDecimal (string? val);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")>]
new Java.Math.BigDecimal : string -> Java.Math.BigDecimal

Parameters

val
String

String representation of BigDecimal.

Attributes

Exceptions

if val does not contain a valid string representation of a big decimal.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Int64)

Translates a long into a BigDecimal.

[Android.Runtime.Register(".ctor", "(J)V", "")]
public BigDecimal (long val);
[<Android.Runtime.Register(".ctor", "(J)V", "")>]
new Java.Math.BigDecimal : int64 -> Java.Math.BigDecimal

Parameters

val
Int64

long value to be converted to BigDecimal.

Attributes

Remarks

Translates a long into a BigDecimal. The scale of the BigDecimal is zero.

Added in 1.5.

Java documentation for java.math.BigDecimal.BigDecimal(.*long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Int32)

Translates an int into a BigDecimal.

[Android.Runtime.Register(".ctor", "(I)V", "")]
public BigDecimal (int val);
[<Android.Runtime.Register(".ctor", "(I)V", "")>]
new Java.Math.BigDecimal : int -> Java.Math.BigDecimal

Parameters

val
Int32

int value to be converted to BigDecimal.

Attributes

Remarks

Translates an int into a BigDecimal. The scale of the BigDecimal is zero.

Added in 1.5.

Java documentation for java.math.BigDecimal.BigDecimal(.*int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Double)

Translates a double into a BigDecimal which is the exact decimal representation of the double's binary floating-point value.

[Android.Runtime.Register(".ctor", "(D)V", "")]
public BigDecimal (double val);
[<Android.Runtime.Register(".ctor", "(D)V", "")>]
new Java.Math.BigDecimal : double -> Java.Math.BigDecimal

Parameters

val
Double

double value to be converted to BigDecimal.

Attributes

Exceptions

if val is infinity or not a number.

Remarks

Translates a double into a BigDecimal which is the exact decimal representation of the double's binary floating-point value. The scale of the returned BigDecimal is the smallest value such that (10<sup>scale</sup> &times; val) is an integer.

<b>Notes:</b> <ol> <li> The results of this constructor can be somewhat unpredictable. One might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625. This is because 0.1 cannot be represented exactly as a double (or, for that matter, as a binary fraction of any finite length). Thus, the value that is being passed <em>in</em> to the constructor is not exactly equal to 0.1, appearances notwithstanding.

<li> The String constructor, on the other hand, is perfectly predictable: writing new BigDecimal("0.1") creates a BigDecimal which is <em>exactly</em> equal to 0.1, as one would expect. Therefore, it is generally recommended that the #BigDecimal(String) String constructor be used in preference to this one.

<li> When a double must be used as a source for a BigDecimal, note that this constructor provides an exact conversion; it does not give the same result as converting the double to a String using the Double#toString(double) method and then using the #BigDecimal(String) constructor. To get that result, use the static#valueOf(double) method. </ol>

Java documentation for java.math.BigDecimal.BigDecimal(.*double).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Char[])

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor.

[Android.Runtime.Register(".ctor", "([C)V", "")]
public BigDecimal (char[]? in);
[<Android.Runtime.Register(".ctor", "([C)V", "")>]
new Java.Math.BigDecimal : char[] -> Java.Math.BigDecimal

Parameters

in
Char[]

char array that is the source of characters.

Attributes

Exceptions

if in does not contain a valid string representation of a big decimal.

Remarks

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor.

Added in 1.5.

Java documentation for java.math.BigDecimal.BigDecimal(.*char[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

BigDecimal(Char[], MathContext)

Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the #BigDecimal(String) constructor and with rounding according to the context settings.

[Android.Runtime.Register(".ctor", "([CLjava/math/MathContext;)V", "")]
public BigDecimal (char[]? in, Java.Math.MathContext? mc);
[<Android.Runtime.Register(".ctor", "([CLjava/math/MathContext;)V", "")>]
new Java.Math.BigDecimal : char[] * Java.Math.MathContext -> Java.Math.BigDecimal

Parameters

in
Char[]

char array that is the source of characters.

mc
MathContext

the context to use.

Attributes

Exceptions

if in does not contain a valid string representation of a big decimal.

if mc.precision > 0 and mc.roundingMode == UNNECESSARY and the new big decimal cannot be represented within the given precision without rounding.

Remarks

Java documentation for java.math.BigDecimal.BigDecimal(char[], java.math.MathContext).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to