Comfy-Org / Comfy-Org/ComfyUI_frontend
Round doubles to prevent "0.10000000000000002" from being displayed
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
### Feature Idea
I have a KSampler Node and I enter for it's denoise the value as 0.1. Given that the value is saved internally as a double it gets saved as 0.10000000000000002. It would be great if ComfyUI would automatically round doubles when they are displayed in the UI in cases like this to have it display 0.1.
---
*This issue is transferred from: https://github.com/comfyanonymous/ComfyUI/issues/8658*
Original issue was created by @ChristianKleineidam at 2025-06-25T06:44:08.000Z
**Original Comments:**
@bigcat88:
Hi! Thanks for reporting this, I made a PR to the Frontend repository with a potential fix - let's hope that it this will work and will be merged :)
@DraconicDragon:
Edit: sorry, i missed [the comment in the PR](https://github.com/Comfy-Org/ComfyUI_frontend/pull/4291#issuecomment-3039028995) about the following being for another PRIt seems like this still is an issue in frontend version 1.24.0 release (even with the above mentioned PR being merged and mentioned in the release notes) for float widgets that have a stepping smaller than 0.1 like the denoise float widget on the core ksampler node (stepping of 0.01)
The cfg widget on the same ksampler node which has a stepping of 0.1 seems to be fixed.
I tried some other nodes like the core "Float" node and it seems to work fine there too (stepping of 0.5) however the "strength_*" floats on the Load LoRA node (stepping of 0.01) show the same issue as the ksampler node's denoise widget
@ChristianKleineidam:
I think the PR did introduce a bug where 0.85 gets sometimes rounded to 0.9. That should not happen the rounding should happen much later.In a Utils/primitive/float node, for me 0.85 gets rounded to 0.9.
@bigcat88:
> I think the PR did introduce a bug where 0.85 gets sometimes rounded to 0.9Can you guide me how I can reproduce this? (as it looks like serious regression)
@ChristianKleineidam:
Yes, it seems like serious regression. I'm not 100% sure whether this issue created the bug or something else. I'm on the nightly build.Right click->Add node->Utils->Primitive->Float adds a float node.
Click on it to add a number, type 0.85 and press enter. It then shows as 0.9.
@ChristianKleineidam:
The rounding function should like be called so that it asserts maybe 10 significant digits and rounds after that. That would be enough to prevent the rounding issues from float being shown while not being a problem for the precision that users actually want
@bigcat88:
As far as I can see, the default rounding is `1` after the dot, so this is expected behavior.
@christian-byrne can you give your opinion, what should the fix look like in such case?
Should we add `"round": False` on the backend for this node?
@ChristianKleineidam:
Rounding makes sense given that the value is stored as a float and displayed as a decimal. But it would be possible to round to 9 significant digits, so that the user the decimals that they entered.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-6414-Round-doubles-to-prevent-0-10000000000000002-from-being-displayed-29c6d73d365081de983bd65a2b83dff2) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.