From acf880c67b49de3d8ba2432d044b252e829524f1 Mon Sep 17 00:00:00 2001 From: Torwent Date: Wed, 18 Dec 2024 14:35:33 +0100 Subject: [PATCH] fix(biohash): Double.GetDigit() users math only again Exact same formula it originally had but without using Simba functions. Thanks slacky! --- utils/math.simba | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/utils/math.simba b/utils/math.simba index ce4b1e31..202e0b06 100644 --- a/utils/math.simba +++ b/utils/math.simba @@ -11,8 +11,7 @@ This file has math related methods. (* ## Double.GetDigit ```pascal -function Double.GetDigit(n: Int32): Int32; -function Double.GetDigit(n: Int64): Int64; overload; +function Double.GetDigit(n: Int32): Integer; ``` Get the digit at the **n** place of the Double. @@ -25,25 +24,9 @@ begin end; ``` *) -function Double.GetDigit(n: Int32): Int32; -var - i: Int32; - str: String; -begin - str := ToStr(Self).Replace('.', ''); - if Length(str) = 0 then Exit; - if not InRange(Inc(n), 1, Length(str)) then Exit; - Result := StrToInt(str[n]); -end; - -function Double.GetDigit(n: Int64): Int64; overload; -var - str: String; +function Double.GetDigit(n: Int32): Integer; begin - str := ToStr(Self).Replace('.', ''); - if Length(str) = 0 then Exit; - if not InRange(Inc(n), 1, Length(str)) then Exit; - Result := StrToInt64(str[n]); + Result := Trunc(Self*10**(n+1)) mod 10; end; (* @@ -52,7 +35,6 @@ end; function NumberPerHour(n: Int64): Int32; function NumberPerHour(n: Double): Int32; overload; ``` - Calculate how many **n** per hour. You can optionally specify the amount of **time** to use in the calculation. Example: