typelevel/spire

Fast-path for rounding `Real`

Opened this issue · 1 comments

Real.roundUp(Rational(value, SafeLong(2).pow(bits - p)))

Pointed out by @s5bug on Discord.

hmm why does it do this instead of a bitshift?
I assume it's something like 0b1.01 should round to 0b1.1, but you can just check a bit for that
instead of having to do a whole GCD

s5bug commented

I'm also guessing that a bitshift can be done in any place where a rational with a power-of-two denominator is used. Such as the division by four in addition.