Using zarith 1.14, I get:
utop # #require "zarith";;
utop # Q.mul_2exp Q.one (-1);;
Exception: Invalid_argument "Z.shift_left: count argument must be positive".
utop # Q.div_2exp Q.one (-1);;
Exception: Invalid_argument "Z.shift_left: count argument must be positive".
I.e. Q.mul_2exp and Q.div_2exp fail when the exponent is negative with a confusing error message.
There is a workaround by checking whether the exponent is negative and then using div_2exp instead of mul_2exp and vice versa.
The functions should be fixed to work with negative exponents too (or the error message should be more meaningful and the behavior documented).
Using
zarith 1.14, I get:I.e.
Q.mul_2expandQ.div_2expfail when the exponent is negative with a confusing error message.There is a workaround by checking whether the exponent is negative and then using
div_2expinstead ofmul_2expand vice versa.The functions should be fixed to work with negative exponents too (or the error message should be more meaningful and the behavior documented).