From 31934d775fc58076fd338f06794d6d436fe8055e Mon Sep 17 00:00:00 2001 From: Dieter Reinert Date: Sat, 4 Jan 2025 21:13:31 +0100 Subject: [PATCH] Calculator: Fix base prefix logic for zero results (#10778) Previously, `/calculate` would fail to include the correct base prefix (`0x`, `0b`, `0o`) when the result was `0` because the code used a falsy check (`if (result)`). This commit replaces that condition with `if (Number.isFinite(result))`, ensuring zero is properly displayed in the requested base. --- server/chat-plugins/calculator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/chat-plugins/calculator.ts b/server/chat-plugins/calculator.ts index 0dff3198b78a..4099448a828d 100644 --- a/server/chat-plugins/calculator.ts +++ b/server/chat-plugins/calculator.ts @@ -180,7 +180,7 @@ export const commands: Chat.ChatCommands = { const [result, inferredBase] = solveRPN(parseMathematicalExpression(expression)); if (!base) base = inferredBase; let baseResult = ''; - if (result && base !== 10) { + if (Number.isFinite(result) && base !== 10) { baseResult = `${BASE_PREFIXES[base]}${result.toString(base).toUpperCase()}`; if (baseResult === expression) baseResult = ''; }