Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here are some possibilities to lift, we may use a list to lift. (A number can also be considered as an element in $\Bbb Z$, and the coercion to $\Bbb F_2=$GF(2) makes it zero or one. So:

sage: F.<t> = GF(2)[]
sage: K.<q> = GF(2^48, name='q', modulus=t^48 + t^28 + t^27 + t + 1, repr='int')
sage: test = 0x944a58ec1f29
sage: test
163047040360233

sage: F(test.digits(base=2))
t^47 + t^44 + t^42 + t^38 + t^35 + t^33 + t^30 + t^28 + t^27 + t^23 + t^22 + t^21 
     + t^19 + t^18 + t^12 + t^11 + t^10 + t^9 + t^8 + t^5 + t^3 + 1
sage: K(test.digits(base=2))
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
     + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

sage: test.binary()
'100101000100101001011000111011000001111100101001'

sage: K(list(test.binary()))    # not what we want!
q^47 + q^44 + q^42 + q^39 + q^38 + q^37 + q^36 + q^35 + q^29 + q^28 + q^26 + q^25 + q^24 
     + q^20 + q^19 + q^17 + q^14 + q^12 + q^9 + q^5 + q^3 + 1
sage: K(list(test.binary())[::-1])
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
      + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

sage: K(test.bits())
q^47 + q^44 + q^42 + q^38 + q^35 + q^33 + q^30 + q^28 + q^27 + q^23 + q^22 + q^21
      + q^19 + q^18 + q^12 + q^11 + q^10 + q^9 + q^8 + q^5 + q^3 + 1

For short, use test.bits() or test.digits(2) as an intermediate step.