scala.runtime.RichLong

final class RichLong extends AnyVal with IntegralProxy[Long]

Type Members

type ResultWithoutStep = NumericRange[Long]

  • Definition Classes
    • IntegralProxy → RangedProxy

Deprecated Value Members From scala.Any

final def ##(): Int

Equivalent to x.hashCode except for boxed numeric types and null . For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException .

  • returns
    • a hash value consistent with ==
  • Definition Classes
    • Any

(defined at scala.Any###)

Value Members From scala.math.Ordered

def <(that: Long): Boolean

Returns true if this is less than that

  • Definition Classes
    • Ordered

(defined at scala.math.Ordered)

def <=(that: Long): Boolean

Returns true if this is less than or equal to that .

  • Definition Classes
    • Ordered

(defined at scala.math.Ordered)

def >(that: Long): Boolean

Returns true if this is greater than that .

  • Definition Classes
    • Ordered

(defined at scala.math.Ordered)

def >=(that: Long): Boolean

Returns true if this is greater than or equal to that .

  • Definition Classes
    • Ordered

(defined at scala.math.Ordered)

def compareTo(that: Long): Int

Result of comparing this with operand that .

  • Definition Classes
    • Ordered → Comparable

(defined at scala.math.Ordered)

Value Members From scala.math.ScalaNumericAnyConversions

def unifiedPrimitiveEquals(x: Any): Boolean

Should only be called after all known non-primitive types have been excluded. This method won’t dispatch anywhere else after checking against the primitives to avoid infinite recursion between equals and this on unknown “Number” variants.

Additionally, this should only be called if the numeric type is happy to be converted to Long, Float, and Double. If for instance a BigInt much larger than the Long range is sent here, it will claim equality with whatever Long is left in its lower 64 bits. Or a BigDecimal with more precision than Double can hold: same thing. There’s no way given the interface available here to prevent this error.

  • Attributes
    • protected
  • Definition Classes
    • ScalaNumericAnyConversions

(defined at scala.math.ScalaNumericAnyConversions)

Value Members From scala.runtime.IntegralProxy

def to(end: Long): Inclusive[Long]

  • Definition Classes
    • IntegralProxy → RangedProxy

(defined at scala.runtime.IntegralProxy)

def to(end: Long, step: Long): Inclusive[Long]

  • Definition Classes
    • IntegralProxy → RangedProxy

(defined at scala.runtime.IntegralProxy)

def until(end: Long): Exclusive[Long]

  • Definition Classes
    • IntegralProxy → RangedProxy

(defined at scala.runtime.IntegralProxy)

def until(end: Long, step: Long): Exclusive[Long]

  • Definition Classes
    • IntegralProxy → RangedProxy

(defined at scala.runtime.IntegralProxy)

Value Members From scala.runtime.OrderedProxy

def compare(y: Long): Int

Result of comparing this with operand that .

Implement this method to determine how instances of A will be sorted.

Returns x where:

  • x < 0 when this < that
  • x == 0 when this == that
  • x > 0 when this > that

  • Definition Classes
    • OrderedProxy → Ordered

(defined at scala.runtime.OrderedProxy)

Instance Constructors From scala.runtime.RichLong

new RichLong(self: Long)

(defined at scala.runtime.RichLong)

Value Members From scala.runtime.RichLong

def max(that: Long): Long

Returns this if this > that or that otherwise.

  • Definition Classes
    • RichLong → ScalaNumberProxy

(defined at scala.runtime.RichLong)

def min(that: Long): Long

Returns this if this < that or that otherwise.

  • Definition Classes
    • RichLong → ScalaNumberProxy

(defined at scala.runtime.RichLong)

def num: LongIsIntegral.type

  • Attributes
    • protected
  • Definition Classes
    • RichLong → IntegralProxy → ScalaNumberProxy (defined at scala.runtime.RichLong)

Full Source:

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2002-2013, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

package scala
package runtime

final class RichLong(val self: Long) extends AnyVal with IntegralProxy[Long] {
  protected def num = scala.math.Numeric.LongIsIntegral
  protected def ord = scala.math.Ordering.Long

  override def doubleValue() = self.toDouble
  override def floatValue()  = self.toFloat
  override def longValue()   = self
  override def intValue()    = self.toInt
  override def byteValue()   = self.toByte
  override def shortValue()  = self.toShort

  override def isValidByte  = self.toByte.toLong == self
  override def isValidShort = self.toShort.toLong == self
  override def isValidChar  = self.toChar.toLong == self
  override def isValidInt   = self.toInt.toLong == self
           def isValidLong  = true
  // override def isValidFloat = self.toFloat.toLong == self && self != Long.MaxValue
  // override def isValidDouble = self.toDouble.toLong == self && self != Long.MaxValue

  override def abs: Long             = math.abs(self)
  override def max(that: Long): Long = math.max(self, that)
  override def min(that: Long): Long = math.min(self, that)
  override def signum: Int           = math.signum(self).toInt
  
  /** There is no reason to round a `Long`, but this method is provided to avoid accidental conversion to `Int` through `Float`. */
  @deprecated("This is an integer type; there is no reason to round it.  Perhaps you meant to call this on a floating-point value?", "2.11.0")
  def round: Long = self

  def toBinaryString: String = java.lang.Long.toBinaryString(self)
  def toHexString: String    = java.lang.Long.toHexString(self)
  def toOctalString: String  = java.lang.Long.toOctalString(self)
}