From 1caee9ae6eecf807e8ded128871fa1741d6dfbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Tue, 14 May 2024 16:52:09 +0200 Subject: [PATCH] Fixed BigInt string initializers --- UBigInt.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/UBigInt.pas b/UBigInt.pas index e90b5c6..74dc5fa 100644 --- a/UBigInt.pas +++ b/UBigInt.pas @@ -390,7 +390,12 @@ var charBlockSize, offset, i, j, k, remainder: Integer; d: Cardinal; begin - charBlockSize := 64 div AFromBase; + // 2 ^ (32 / charBlockSize) = AFromBase + case AFromBase of + 2: charBlockSize := 32; + 16: charBlockSize := 8; + end; + if AValue[1] = '-' then begin offset := 2; @@ -402,7 +407,7 @@ begin end; // Calculates the first (most significant) digit d of the result. - DivMod(AValue.Length - offset, charBlockSize, i, remainder); + DivMod(AValue.Length - offset + 1, charBlockSize, i, remainder); k := offset; d := 0; // Checks the first block of chars that is not a full block.