Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

fix the code for convertBigintToBase in the spec #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions IOTA-Kerl-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def convertBigintToTrits(bigInt):
```
def convertBigintToBase(bigInt,base,length):
is_negative = bigInt < 0
absolute_value = abs(bigInt)
quotient = abs(bigInt)
MAX = is_negative ? base/2 : (base-1)/2

for i=1:length:
quotient,remainder = divmod(absolute_value, base)
quotient,remainder = divmod(quotient, base)
if remainder > MAX:
# Lend 1 to the next place so we can make this digit negative.
quotient += 1
Expand Down