Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Changing the meaning of /

I have a program that makes some calculations in a ring R, where R may be either approximate real numbers (for which I am using RealField(20), or approximate p-adic numbers, for which I use Zp(p,prec=numbits).

I need to do division. If R is RealField, I can just use /, but // is undefined. If R is Zp, / complains if the denominator is a non-unit. Fine, this makes sense, but I want it to makes its best guess, which is implemented by //.

Anyway, the formulas I have involve dividing. I'd rather use the same functions for some calculations, no matter what R is. How can I overload / in Zp to do what // does, even in the case of non-units? Or // in RealField() to be /?