Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
Is there a way to constrain a Double
to "just smaller than 1.0" such that (aDouble * aPositiveInt).toInt < aPositiveInt
is guaranteed to hold? I.e. I don't want to perform that check after each multiplication. Like I can empircally get a very long literal:
assert (0.999999999999999944488848768742172978818416595 < 1)
assert ((0.999999999999999944488848768742172978818416595 * Int.MaxValue).toInt < Int.MaxValue)
But I wasn't patient enough to keep looking for the digits (seems there are more)