Skip to content

Add Convert Data Type Node #8205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

LaVie024
Copy link
Contributor

Per my previous PR, I initially created five nodes, though it became obvious that it couldn't work out. I then learned of the existence of Impact Pack's Convert Data Type node, which is what this node is largely based upon. I decided to add more options to the float as per my previous PR had, as well as the ability to also output a combo. Returns null on int and float output if the string cannot be converted to a float.

2025-05-19_14-45

The main functions this introduces:

  1. The user is able to choose what rounding type to use on a float or a string representing a float before it is converted to an integer. We are able to choose to just truncate, round, or do banker's rounding on a float.
  2. The user is able to choose if a float is to be rounded before being converted to a string, and to choose how many decimal points, or to just display the full float.

Mainly, this is meant to be an extremely simple method to convert data types without needing a node for each type to be converted.

@webfiltered
Copy link
Collaborator

@Amorano
Copy link
Contributor

Amorano commented May 20, 2025

return {"required": {"value": ("*"),
"int_mode": (["truncate","round","bankers_rounding"],),
"string_round_value": ("BOOLEAN", {"default": True}),
"string_round_to": ("INT", {"default": 2, "min": 0})
Copy link

@andkhong andkhong May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a max?
Is it possible for the UI to allow for people to set the string_round_to higher than available digits?

For example,
value: 2.71828 and string_round_to: 10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the available digits are higher than the float, it will just produce 0s in those places. For instance, if we have a float of value 1.5, and set string_round_to to 2, it will simply output 1.50.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can imagine someone potentially setting string_round_to to a massive value like 100 if float value is 1.5 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants