broken nextpow functions #4819
Labels
bug
Indicates an unexpected problem or unintended behavior
needs decision
A decision on this change is needed
Milestone
I've been looking at the
prevpow
/nextpow
functions, and they seem somewhat broken to me:nextpow2(n) != nextpow2(2, n)
: the former returns the power-of-2 value, and the latter returns the exponent. e.g.nextpow2(9)
is16
, butnextpow(2, 9)
is4
. Similarly forprevpow
.nextpow2(0) == prevpow2(0) == 0
. I can only understand this behavior under the theory that zero is 2^–∞, but that seems questionable to me.nextpow(2, 0)
andprevpow(2, 0)
raise anInexactError
(I would have expected aDomainError
, maybe?).prevpow(2, 1)
correctly returns 0 (1 == 2^0, see first point), butnextpow(2, 1)
throws aDomainError
, which is certainly wrong.nextpow(2, -7)
andprevpow(2, -7)
raiseDomainError
s, butnextpow2(-7)
gives-8
andprevpow2(-7)
gives-4
.The text was updated successfully, but these errors were encountered: