Information addition not always works as expected.
Bytes(Double.MaxValue / 2.0) == (Bytes(Double.MaxValue / 2.0) + Bytes(1.0)) will evaluate to true
This happens because Information's underlying type is Double. Not sure about reasons to choose this, it seems that Long should suit these needs better.
- Change the args to Information like so
final class Information private(val amount: Long, val unit: InformationUnit) extends Quantity[Information] with TimeIntegral[DataRate] {
- Add this to the Information class as well: def value = amount.toDouble
// overridden to remove the forcing of doubles for this unit that makes // no sense now that this dimension is represented by a long override def toString(): String = s"$amount ${unit.symbol}" override def toString(uom: UnitOfMeasure[Information]): String = in(uom).toString()
-
In the Information object: change the first apply method like so (toDouble becomes toLong): private[information] def apply[A](n: A, unit: InformationUnit)(implicit num: Numeric[A]) = new Information(num.toLong(n), unit)
-
Change the InformationSpec test to remove the .0 from the expected strings in the string formatting test
Go ahead and make that PR for yourself and push it back...