diff --git a/web/scripts/ui.js b/web/scripts/ui.js index aa93a62b2..1e7920167 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -584,6 +584,18 @@ export class ComfyUI { defaultValue: false, }); + this.settings.addSetting({ + id: "Comfy.FloatRoundingPrecision", + name: "Decimal places [0 = auto] (requires page reload).", + type: "slider", + attrs: { + min: 0, + max: 6, + step: 1, + }, + defaultValue: 0, + }); + const fileInput = $el("input", { id: "comfy-file-input", type: "file", diff --git a/web/scripts/widgets.js b/web/scripts/widgets.js index 0cb307880..790928d14 100644 --- a/web/scripts/widgets.js +++ b/web/scripts/widgets.js @@ -12,7 +12,10 @@ function getNumberDefaults(inputData, defaultStep, app) { // when using the old behavior, it defaults to 3 decimal places let precision = 3; let round = 0.001; - if (!app.ui.settings.getSettingValue("Comfy.DisableFloatRounding")) { + if (app.ui.settings.getSettingValue("Comfy.FloatRoundingPrecision") > 0) { + precision = app.ui.settings.getSettingValue("Comfy.FloatRoundingPrecision"); + round = Math.round(1000000*Math.pow(0.1,precision))/1000000; + } else if (!app.ui.settings.getSettingValue("Comfy.DisableFloatRounding")) { // display the the smallest number of decimal places such that changes of size step are visible. precision = Math.max(-Math.floor(Math.log10(step)),0); // round the value to those decimal places shown.