Skip to content

Commit

Permalink
Fix off by one in num2text (#1654)
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle authored Feb 4, 2024
1 parent 1865ba5 commit 8ad20c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Content.Tests/DMProject/Tests/Text/num2text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@

// Zero/Negative MinDigits
ASSERT(num2text(1, 0, 10) == "1")
ASSERT(num2text(1, -1, 10) == "1")
ASSERT(num2text(1, -1, 10) == "1")
ASSERT(num2text(0, 0, 16) == "0")
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ public static DreamValue NativeProc_num2text(NativeProc.Bundle bundle, DreamObje
}

if(bundle.Arguments.Length == 3) {
var digits = Math.Max(bundle.GetArgument(1, "A").MustGetValueAsInteger(), 0);
var digits = Math.Max(bundle.GetArgument(1, "A").MustGetValueAsInteger(), 1);
var radix = bundle.GetArgument(2, "B").MustGetValueAsInteger();
var intNum = (int)floatNum;

Expand Down

0 comments on commit 8ad20c8

Please sign in to comment.