Scala Library
|
|
scala/math/BigDecimal.scala
]
class
BigDecimal(val
bigDecimal : java.math.BigDecimal, val
mc : java.math.MathContext)
extends
ScalaNumericConversionsAdditional Constructor Summary | |
def
|
this (bigDecimal : java.math.BigDecimal) : BigDecimal |
Method Summary | |
def
|
*
(that : BigDecimal) : BigDecimal
Multiplication of BigDecimals
|
def
|
+
(that : BigDecimal) : BigDecimal
Addition of BigDecimals
|
def
|
-
(that : BigDecimal) : BigDecimal
Subtraction of BigDecimals
|
def
|
/
(that : BigDecimal) : BigDecimal
Division of BigDecimals
|
def
|
/%
(that : BigDecimal) : (BigDecimal, BigDecimal)
Division and Remainder - returns tuple containing the result of
divideToIntegralValue and the remainder.
|
def
|
<
(that : BigDecimal) : Boolean
Less-than of BigDecimals
|
def
|
<=
(that : BigDecimal) : Boolean
Less-than-or-equals comparison of BigDecimals
|
def
|
>
(that : BigDecimal) : Boolean
Greater-than comparison of BigDecimals
|
def
|
>=
(that : BigDecimal) : Boolean
Greater-than-or-equals comparison of BigDecimals
|
def
|
abs
: BigDecimal
Returns the absolute value of this BigDecimal
|
def
|
apply
(mc : java.math.MathContext) : BigDecimal
Returns a new BigDecimal based on the supplied MathContext.
|
override def
|
byteValue
: Byte
Converts this BigDecimal to a byte.
If the BigDecimal is too big to fit in a byte, only the low-order 8 bits are returned.
Note that this conversion can lose information about the overall magnitude of the
BigDecimal value as well as return a result with the opposite sign.
|
def
|
charValue
: Char
Converts this BigDecimal to a char.
If the BigDecimal is too big to fit in a char, only the low-order 16 bits are returned.
Note that this conversion can lose information about the overall magnitude of the
BigDecimal value and that it always returns a positive result.
|
def
|
compare
(that : BigDecimal) : Int
Compares this BigDecimal with the specified BigDecimal
|
def
|
doubleValue
: Double
Converts this BigDecimal to a Double.
if this BigDecimal has too great a magnitude to represent as a double,
it will be converted to
Double.NEGATIVE_INFINITY or
Double.POSITIVE_INFINITY as appropriate. |
override def
|
equals
(that : Any) : Boolean
Compares this BigDecimal with the specified value for equality.
Will only claim equality with scala.BigDecimal and java.math.BigDecimal.
|
def
|
equals
(that : BigDecimal) : Boolean
Compares this BigDecimal with the specified BigDecimal for equality.
|
def
|
floatValue
: Float
Converts this BigDecimal to a float.
if this BigDecimal has too great a magnitude to represent as a float,
it will be converted to
Float.NEGATIVE_INFINITY or
Float.POSITIVE_INFINITY as appropriate. |
override def
|
hashCode
: Int
Returns the hash code for this BigDecimal.
Note that this does not use the underlying java object's
hashCode because we compare BigDecimals with compareTo
which deems 2 == 2.00, whereas in java these are unequal
with unequal hashCodes.
|
def
|
intValue
: Int
Converts this BigDecimal to an int.
If the BigDecimal is too big to fit in a char, only the low-order 32 bits
are returned. Note that this conversion can lose information about the
overall magnitude of the BigDecimal value as well as return a result with
the opposite sign.
|
protected override def
|
isWhole : Boolean |
def
|
longValue
: Long
Converts this BigDecimal to a Long.
If the BigDecimal is too big to fit in a char, only the low-order 64 bits
are returned. Note that this conversion can lose information about the
overall magnitude of the BigDecimal value as well as return a result with
the opposite sign.
|
def
|
max
(that : BigDecimal) : BigDecimal
Returns the maximum of this and that
|
def
|
min
(that : BigDecimal) : BigDecimal
Returns the minimum of this and that
|
def
|
pow
(n : Int) : BigDecimal
Returns a BigDecimal whose value is this* n.
|
def
|
precision
: Int
Returns the precision of this
BigDecimal . |
def
|
quot
(that : BigDecimal) : BigDecimal
Divide to Integral value.
|
def
|
remainder
(that : BigDecimal) : BigDecimal
Remainder after dividing this by that.
|
def
|
round
(mc : java.math.MathContext) : BigDecimal
Returns a BigDecimal rounded according to the MathContext settings.
|
def
|
scale
: Int
Returns the scale of this
BigDecimal . |
def
|
setScale (scale : Int, mode : Value) : BigDecimal |
def
|
setScale
(scale : Int) : BigDecimal
Returns a
BigDecimal whose scale is the specified value, and whose value is
numerically equal to this BigDecimal's. |
override def
|
shortValue
: Short
Converts this BigDecimal to a short.
If the BigDecimal is too big to fit in a byte, only the low-order 16 bits are returned.
Note that this conversion can lose information about the overall magnitude of the
BigDecimal value as well as return a result with the opposite sign.
|
def
|
signum
: Int
Returns the sign of this BigDecimal, i.e.
-1 if it is less than 0,
+1 if it is greater than 0
0 if it is equal to 0
|
def
|
to
(end : BigDecimal, step : BigDecimal) : Inclusive[BigDecimal]
Like
until , but inclusive of the end value. |
def
|
to
(end : BigDecimal) : Partial[BigDecimal, Inclusive[BigDecimal]]
Like
until , but inclusive of the end value. |
def
|
toBigInt
: BigInt
Converts this
BigDecimal to a scala.BigInt. |
def
|
toBigIntExact
: Option[BigInt]
Converts this
BigDecimal to a scala.BigInt if it
can be done losslessly, returning Some(BigInt) or None. |
def
|
toByteExact
: Byte
This BigDecimal as an exact value.
|
def
|
toIntExact : Int |
def
|
toLongExact : Long |
def
|
toShortExact : Short |
override def
|
toString
: java.lang.String
Returns the decimal String representation of this BigDecimal.
|
def
|
ulp
: BigDecimal
Returns the size of an ulp, a unit in the last place, of this BigDecimal.
|
def
|
unary_-
: BigDecimal
Returns a BigDecimal whose value is the negation of this BigDecimal
|
def
|
until
(end : BigDecimal, step : BigDecimal) : Exclusive[BigDecimal]
Same as the one-argument
until , but creates the range immediately. |
def
|
until
(end : BigDecimal) : Partial[BigDecimal, Exclusive[BigDecimal]]
Creates a partially constructed NumericRange[BigDecimal] in range
[start;end) , where start is the target BigDecimal. The step
must be supplied via the "by" method of the returned object in order
to receive the fully constructed range. For example:
val partial = BigDecimal(1.0) to 2.0 // not usable yet val range = partial by 0.01 // now a NumericRange val range2 = BigDecimal(0) to 1.0 by 0.01 // all at once of course is fine too |
Methods inherited from ScalaNumericConversions | |
toChar, toByte, toShort, toInt, toLong, toFloat, toDouble, isValidByte, isValidShort, isValidInt, isValidChar, unifiedPrimitiveHashcode, unifiedPrimitiveEquals |
Methods inherited from AnyRef | |
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Additional Constructor Details |
Method Details |
override
def
hashCode : Int
protected override
def
isWhole : Boolean
def
equals(that : BigDecimal) : Boolean
def
compare(that : BigDecimal) : Int
def
<=(that : BigDecimal) : Boolean
def
>=(that : BigDecimal) : Boolean
def
<(that : BigDecimal) : Boolean
def
>(that : BigDecimal) : Boolean
def
+(that : BigDecimal) : BigDecimal
def
-(that : BigDecimal) : BigDecimal
def
*(that : BigDecimal) : BigDecimal
def
/(that : BigDecimal) : BigDecimal
def
/%(that : BigDecimal) : (BigDecimal, BigDecimal)
def
quot(that : BigDecimal) : BigDecimal
def
min(that : BigDecimal) : BigDecimal
def
max(that : BigDecimal) : BigDecimal
def
remainder(that : BigDecimal) : BigDecimal
def
pow(n : Int) : BigDecimal
def
unary_- : BigDecimal
def
abs : BigDecimal
def
signum : Int
def
precision : Int
BigDecimal
.
def
round(mc : java.math.MathContext) : BigDecimal
def
scale : Int
BigDecimal
.
def
ulp : BigDecimal
def
apply(mc : java.math.MathContext) : BigDecimal
def
setScale(scale : Int) : BigDecimal
BigDecimal
whose scale is the specified value, and whose value is
numerically equal to this BigDecimal's.
def
setScale(scale : Int, mode : Value) : BigDecimal
override
def
byteValue : Byte
override
def
shortValue : Short
def
charValue : Char
def
intValue : Int
def
longValue : Long
def
floatValue : Float
Float.NEGATIVE_INFINITY
or
Float.POSITIVE_INFINITY
as appropriate.
def
doubleValue : Double
Double.NEGATIVE_INFINITY
or
Double.POSITIVE_INFINITY
as appropriate.
def
toByteExact : Byte
def
toShortExact : Short
def
toIntExact : Int
def
toLongExact : Long
def
until(end : BigDecimal) : Partial[BigDecimal, Exclusive[BigDecimal]]
[start;end)
, where start is the target BigDecimal. The step
must be supplied via the "by" method of the returned object in order
to receive the fully constructed range. For example:
val partial = BigDecimal(1.0) to 2.0 // not usable yet val range = partial by 0.01 // now a NumericRange val range2 = BigDecimal(0) to 1.0 by 0.01 // all at once of course is fine too
end -
the end value of the range (exclusive)
def
until(end : BigDecimal, step : BigDecimal) : Exclusive[BigDecimal]
until
, but creates the range immediately.
def
to(end : BigDecimal) : Partial[BigDecimal, Inclusive[BigDecimal]]
until
, but inclusive of the end value.
def
to(end : BigDecimal, step : BigDecimal) : Inclusive[BigDecimal]
until
, but inclusive of the end value.
def
toBigInt : BigInt
BigDecimal
to a scala.BigInt.BigDecimal
to a scala.BigInt if it
can be done losslessly, returning Some(BigInt) or None.override
def
toString : java.lang.String
Scala Library
|
|