Nodes/ComfyUI_DD_Nodes/DD Float to Int
ComfyUI Node

DD Float to Int

Round, floor, ceil, or truncate — pick your poison

By digital-divas-admin·Created 7 months ago·Updated 5 months ago· 0
DD Float to Int
    • int_value
    value0.00
    moderound

    Every ComfyUI user eventually hits the wall where a node hands you 3.7 and the next node wants a whole number. DD Float to Int is the conversion node that lets you decide how that 3.7 becomes an integer - and that choice matters more than you'd think, because "3.7 rounded" depends entirely on which rounding rule you're using. The node gives you four of them on a dropdown.

    The four modes

    One input, value (FLOAT, default 0.0, stepped at 0.01), and one mode selector:

    • round - nearest integer. 3.7 → 4, 3.2 → 3.
    • floor - always down. 3.7 → 3, even -0.2 → -1.
    • ceil - always up. 3.2 → 4, even 3.0 → 3.
    • truncate - chop off the fraction toward zero. 3.7 → 3, -3.7 → -3.

    Output is int_value (INT), the converted integer.

    The gotcha that will absolutely catch you

    "round" here is Python's round(), which uses banker's rounding: it rounds to the nearest even number at exact halves. So round(2.5) gives 2, not 3, while round(3.5) gives 4. If you were raised on "half rounds up" from math class, this will surprise you the first time a resolution or step count comes out one short. When that matters, floor/ceil/truncate are unambiguous; when you truly need classic half-up, add 0.5 and use floor. Good to know before it eats a workflow run.

    Where you'll use it

    Every time you compute something fractional and need a whole number to plug into an INT-only input: converting a computed denoise or CFG value into step counts, rounding a scaled dimension from math nodes up to the nearest integer, or normalizing a float output from DD Float Math so it can drive a seed or batch size. It's the natural companion to DD Int to Float - together they make the DD math family a complete little toolkit.

    Installing it

    Part of the ComfyUI_DD_Nodes pack by Digital Divas. ComfyUI Manager → search "DD Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/digital-divas-admin/ComfyUI_DD_Nodes.git
    

    Restart ComfyUI. The pack's requirements.txt is empty - no extra Python packages, no model downloads. When Manager returns results, double-check you're installing digital-divas-admin/ComfyUI_DD_Nodes and not the unrelated project that shares the "DD-Nodes" name.

    CategoryDD Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    valueFLOAT0.00
    modeCOMBOround4 options: round, floor, ceil, truncate

    Outputs (1)

    NameTypeDescription
    int_valueINT