File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/sage/rings/finite_rings Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,8 @@ cdef class FiniteRingElement(CommutativeRingElement):
138138 sage: a. to_bytes( byteorder='little')
139139 b'\x16 "\x00 '
140140 """
141- length = (self .parent().order().nbits() + 7 ) // 8
141+ order = self .parent().order()
142+ length = ((order - 1 ).nbits() + 7 ) // 8
142143 return int (self ).to_bytes(length = length, byteorder = byteorder)
143144
144145 def canonical_associate (self ):
@@ -1128,8 +1129,18 @@ cdef class FinitePolyExtElement(FiniteRingElement):
11281129 sage: a = 136* z3^ 2 + 10* z3 + 125
11291130 sage: a. to_bytes( )
11301131 b'7)\xa3 '
1132+
1133+ TESTS:
1134+
1135+ Check that :issue:`41545` is fixed::
1136+
1137+ sage: F. <z2> = GF( 2^ 8)
1138+ sage: a = F. from_integer( 137)
1139+ sage: a. to_bytes( )
1140+ b'\x89 '
11311141 """
1132- length = (self .parent().order().nbits() + 7 ) // 8
1142+ order = self .parent().order()
1143+ length = ((order - 1 ).nbits() + 7 ) // 8
11331144 return self .to_integer().to_bytes(length = length, byteorder = byteorder)
11341145
11351146cdef class Cache_base(SageObject):
You can’t perform that action at this time.
0 commit comments