From 8ad20c85af36324fbb262edbfec51d3e977de638 Mon Sep 17 00:00:00 2001 From: Amy <3855802+amylizzle@users.noreply.github.com> Date: Sun, 4 Feb 2024 06:30:28 +0000 Subject: [PATCH] Fix off by one in `num2text` (#1654) --- Content.Tests/DMProject/Tests/Text/num2text.dm | 3 ++- OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Content.Tests/DMProject/Tests/Text/num2text.dm b/Content.Tests/DMProject/Tests/Text/num2text.dm index 5bf7648627..1d5b311f39 100644 --- a/Content.Tests/DMProject/Tests/Text/num2text.dm +++ b/Content.Tests/DMProject/Tests/Text/num2text.dm @@ -19,4 +19,5 @@ // Zero/Negative MinDigits ASSERT(num2text(1, 0, 10) == "1") - ASSERT(num2text(1, -1, 10) == "1") \ No newline at end of file + ASSERT(num2text(1, -1, 10) == "1") + ASSERT(num2text(0, 0, 16) == "0") \ No newline at end of file diff --git a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs index 17c3fe2e53..a208839762 100644 --- a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs +++ b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs @@ -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;