Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #50 from igormcoelho/fix_bigint_zero_to_byte_array
Browse files Browse the repository at this point in the history
according to C#, BigInteger(0) is b'\x00'
  • Loading branch information
metachris committed May 30, 2018
2 parents 8d6ed7e + 60e434d commit 6b130f6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions neocore/BigInteger.py
Expand Up @@ -15,6 +15,9 @@ def Equals(self, other):
return super(BigInteger, self).__eq__(other)

def ToByteArray(self, signed=True):
if self == 0:
return b'\x00'

if self < 0:
return self.to_bytes(1 + ((self.bit_length() + 7) // 8), byteorder='little', signed=True)

Expand Down

0 comments on commit 6b130f6

Please sign in to comment.