Skip to content

Commit

Permalink
fix(biohash): Double.GetDigit() users math only again
Browse files Browse the repository at this point in the history
Exact same formula it originally had but without using Simba functions. Thanks slacky!
  • Loading branch information
Torwent committed Dec 18, 2024
1 parent e35d802 commit acf880c
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions utils/math.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

(*
Expand All @@ -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:
Expand Down

0 comments on commit acf880c

Please sign in to comment.