Files
CavinHuang-comfyui-nodes-docs/docs/Integer place counter.md
2024-05-26 20:35:16 +08:00

1.2 KiB

Documentation

该节点旨在计算一个整数值中的位数。它作为基础工具,用于需要进行位数计数操作的应用,例如数值分析或数据处理。

Input types

Required

  • int_input
    • 要确定位数的整数输入。它是节点操作的主要数据元素,直接影响结果。
    • Comfy dtype: INT
    • Python dtype: int

Output types

  • INT_PLACES
    • 输出代表提供的整数中的位数计数。对于需要知道数字位数长度的应用来说,它是重要的。
    • Comfy dtype: INT
    • Python dtype: int

Usage tips

  • Infra type: CPU

Source code

class WAS_Integer_Place_Counter:

    @classmethod
    def INPUT_TYPES(cls):
        return {'required': {'int_input': ('INT', {'default': 0, 'min': 0, 'max': 10000000, 'step': 1})}}
    RETURN_TYPES = ('INT',)
    RETURN_NAMES = ('INT_PLACES',)
    FUNCTION = 'count_places'
    CATEGORY = 'WAS Suite/Integer'

    def count_places(self, int_input):
        output = len(str(int_input))
        cstr('\nInteger Places Count: ' + str(output)).msg.print()
        return (output,)