summaryrefslogtreecommitdiff
path: root/src/library/scala/BigDecimal.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-10-19 22:17:19 +0000
committerPaul Phillips <paulp@improving.org>2009-10-19 22:17:19 +0000
commit1e452efbc159bcd553871a44cb697413cc6fc1bd (patch)
treebc06eaf8c6f8b3f3bdd38552943a479faeaff692 /src/library/scala/BigDecimal.scala
parent5eeb2a3b439419e1f6b17925c439346a3cab017d (diff)
downloadscala-1e452efbc159bcd553871a44cb697413cc6fc1bd.tar.gz
scala-1e452efbc159bcd553871a44cb697413cc6fc1bd.tar.bz2
scala-1e452efbc159bcd553871a44cb697413cc6fc1bd.zip
Another bunch of work on Numeric, Range, Generi...
Another bunch of work on Numeric, Range, GenericRange, BigDecimal, and a pile of test cases for various aspects of GenericRange.
Diffstat (limited to 'src/library/scala/BigDecimal.scala')
-rw-r--r--src/library/scala/BigDecimal.scala17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/library/scala/BigDecimal.scala b/src/library/scala/BigDecimal.scala
index 39b3f4b571..fc874db1f2 100644
--- a/src/library/scala/BigDecimal.scala
+++ b/src/library/scala/BigDecimal.scala
@@ -46,6 +46,15 @@ object BigDecimal
val defaultMathContext = MathContext.UNLIMITED
+ /** Constructs a <code>BigDecimal</code> using the java BigDecimal static
+ * valueOf constructor.
+ *
+ * @param d the specified double value
+ * @return the constructed <code>BigDecimal</code>
+ */
+ def valueOf(d: Double): BigDecimal = apply(BigDec valueOf d)
+ def valueOf(d: Double, mc: MathContext): BigDecimal = apply(BigDec valueOf d, mc)
+
/** Constructs a <code>BigDecimal</code> whose value is equal to that of the
* specified <code>Integer</code> value.
*
@@ -144,7 +153,7 @@ object BigDecimal
implicit def long2bigDecimal(l: Long): BigDecimal = apply(l)
/** Implicit conversion from <code>Double</code> to <code>BigDecimal</code>. */
- implicit def double2bigDecimal(d: Double): BigDecimal = apply(d)
+ implicit def double2bigDecimal(d: Double): BigDecimal = valueOf(d, defaultMathContext)
}
/**
@@ -337,9 +346,9 @@ extends jl.Number with ScalaNumericConversions
def floatValue = this.bigDecimal.floatValue
/** Converts this BigDecimal to a <tt>Double</tt>.
- * if this BigDecimal has too great a magnitude to represent as a float,
- * it will be converted to <code>Float.NEGATIVE_INFINITY</code> or
- * <code>Float.POSITIVE_INFINITY</code> as appropriate.
+ * if this BigDecimal has too great a magnitude to represent as a double,
+ * it will be converted to <code>Double.NEGATIVE_INFINITY</code> or
+ * <code>Double.POSITIVE_INFINITY</code> as appropriate.
*/
def doubleValue = this.bigDecimal.doubleValue