diff options
author | Paul Phillips <paulp@improving.org> | 2009-06-24 15:19:09 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-06-24 15:19:09 +0000 |
commit | 1c9870541fb22ac032edaa0be0103cc1aa2c99b4 (patch) | |
tree | 881d38aa5dfba0542295e7e56e642a77cd3852b6 /src/library/scala/BigDecimal.scala | |
parent | 6ab1f0b7710af132401848bc25da9101a364093b (diff) | |
download | scala-1c9870541fb22ac032edaa0be0103cc1aa2c99b4.tar.gz scala-1c9870541fb22ac032edaa0be0103cc1aa2c99b4.tar.bz2 scala-1c9870541fb22ac032edaa0be0103cc1aa2c99b4.zip |
More work and documentation for GenericRanges, ...
More work and documentation for GenericRanges, plus minor findbugs
noticed issues.
Diffstat (limited to 'src/library/scala/BigDecimal.scala')
-rw-r--r-- | src/library/scala/BigDecimal.scala | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/library/scala/BigDecimal.scala b/src/library/scala/BigDecimal.scala index b4d4732951..020a58edc9 100644 --- a/src/library/scala/BigDecimal.scala +++ b/src/library/scala/BigDecimal.scala @@ -345,10 +345,30 @@ extends java.lang.Number def intValueExact: Int = bigDecimal.intValueExact def longValueExact: Long = bigDecimal.longValueExact - /** See <code>Iterator.range</code>. */ + /** Creates a partially constructed GenericRange[BigDecimal] in range + * <code>[start;end)</code>, 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: + * <pre> + * val partial = BigDecimal(1.0) to 2.0 // not usable yet + * val range = partial by 0.01 // now a GenericRange + * val range2 = BigDecimal(0) to 1.0 by 0.01 // all at once of course is fine too + * </pre> + * + * @param end the end value of the range (exclusive) + * @return the partially constructed GenericRange + */ + def until(end: BigDecimal): Range.Partial[BigDecimal, GenericRange.Exclusive[BigDecimal]] = + new Range.Partial(until(end, _)) + + /** Same as the one-argument <code>until</code>, but creates the range immediately. */ def until(end: BigDecimal, step: BigDecimal) = Range.BigDecimal(this, end, step) - /** like <code>until</code>, but includes the last index */ + /** Like <code>until</code>, but inclusive of the end value. */ + def to(end: BigDecimal): Range.Partial[BigDecimal, GenericRange.Inclusive[BigDecimal]] = + new Range.Partial(to(end, _)) + + /** Like <code>until</code>, but inclusive of the end value. */ def to(end: BigDecimal, step: BigDecimal) = Range.BigDecimal.inclusive(this, end, step) /** Converts this <code>BigDecimal</code> to a scala.BigInt. |