From 6e97f00d52be3866c5cb72d84f4985d1c173f073 Mon Sep 17 00:00:00 2001 From: Tyler Cooper Date: Tue, 19 Aug 2025 09:51:52 -0500 Subject: [PATCH] Update round.js --- app/blocks/math/round.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/blocks/math/round.js b/app/blocks/math/round.js index ea9e22f..73f989f 100644 --- a/app/blocks/math/round.js +++ b/app/blocks/math/round.js @@ -4,47 +4,40 @@ export default { bytecodeKey: "round", name: "Round/Floor/Ceiling", color: 120, - description: "Round a value to the nearest whole number via round, floor, or ceiling functions", - + description: "Convert decimal numbers to whole numbers using different rounding strategies. Perfect for cleaning up sensor readings (23.7°F → 24°F), creating clean display values (3.14159 → 3), or preparing data for systems that only accept integers. Choose round for normal rounding, floor for always rounding down, or ceiling for always rounding up.", connections: { mode: "value", output: "expression", }, - inputs: { VALUE: { - description: "A value you'd like to round to a whole number. Will be coerced to a number.", + description: "The decimal number you want to convert to a whole number. Examples: sensor readings like 72.8°F, calculated values like 3.14159, or any numerical data that needs to be simplified. Non-numeric values will be automatically converted to numbers where possible.", bytecodeProperty: "value", check: "expression", shadow: "io_math_number" } }, - fields: { OPERATION: { - description: "Select which rounding operation to perform on the input:", + description: "Choose how to convert your decimal to a whole number:", options: [ - ["Round", "round", "if .5 or higher: round up; otherwise round down"], - ["Floor", "floor", "rounds down"], - ["Ceiling", "ceiling", "rounds up"], + ["Round", "round", "Standard rounding: 0.5 or higher rounds up, below 0.5 rounds down (e.g., 23.7 → 24, 23.4 → 23, 23.5 → 24). Best for general use and displaying clean values."], + ["Floor", "floor", "Always rounds down to the nearest whole number, regardless of decimal value (e.g., 23.9 → 23, 23.1 → 23). Perfect for counting items, time calculations, or when you need conservative estimates."], + ["Ceiling", "ceiling", "Always rounds up to the nearest whole number, regardless of decimal value (e.g., 23.1 → 24, 23.9 → 24). Great for capacity planning, ensuring minimum values, or safety margins."], ], bytecodeProperty: "operation", } }, - template: "%OPERATION %VALUE", - generators: { json: (block, generator) => { const value = JSON.parse(generator.valueToCode(block, 'VALUE', 0)), operation = block.getFieldValue('OPERATION'), payload = { round: { value, operation } } - return [ JSON.stringify(payload), 0 ] } }, - regenerators: { json: (blockObject, helpers) => { const @@ -55,7 +48,6 @@ export default { fields = { OPERATION: operation, } - return { type: 'io_math_round', inputs, fields } } }