object
FastMaybeFloat extends AnyRef
Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
val
Invalid: Long(-1L)
-
def
apply(x: Rational): Long
-
def
apply(x: BigDecimal): Long
-
def
apply(x: BigInt): Long
-
def
apply(x: Long): Long
-
def
apply(x: Int): Long
-
def
apply(x: Double): Long
-
def
apply(x: Float): Long
-
final
def
approx(mf: Long): Float
-
def
asFloat(x: Long): Float
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
div(a: Long, b: Long): Long
-
final
val
eps: Float
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
final
def
error(mf: Long): Float
-
def
finalize(): Unit
-
final
def
getClass(): java.lang.Class[_]
-
def
hashCode(): Int
-
final
def
index(mf: Long): Int
-
def
invalid(a: Long): Boolean
-
final
def
isInstanceOf[T0]: Boolean
-
def
max(a: Int, b: Int): Int
-
final
def
measure(mf: Long): Float
-
def
min(a: Int, b: Int): Int
-
final
def
minus(a: Long, b: Long): Long
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
def
nroot(a: Long, n: Int): Long
-
final
def
plus(a: Long, b: Long): Long
-
def
pow(a: Long, k: Int): Long
-
def
sqrt(a: Long): Long
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
final
def
times(a: Long, b: Long): Long
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
A
Long
encoded version ofMaybeDouble
, geared for unboxed speed. This is significantly less accurate, but may provide good speed gains in common cases.The values
approx
andmeasure
are both truncated floats with the full 8 bit exponent, but only 16 bit mantissa. Since themeasure
is always positive, we only need2 * (16 + 8) + 1 = 49
bits for these 2 numbers, which leaves 15 bits for theindex
. These sizes were chosen so that worst case relative error,ind * eps
, has a value less than 1. In our case, with worst caseind = -1 >>> 17
, we haveind * eps =~ 0.5
.This was inspired by Erik Osheim's awesome FastComplex, which encodes the imaginary and real parts as 2
Float
s in the a singleLong
.TODO: Perhaps, if we've only used + or *, we could store a higher precision float instead, since we don't need measure. Use 1 bit to handle the switching, taken from the index.