-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
base: master
Are you sure you want to change the base?
Conversation
return {"required": {"value": ("*"), | ||
"int_mode": (["truncate","round","bankers_rounding"],), | ||
"string_round_value": ("BOOLEAN", {"default": True}), | ||
"string_round_to": ("INT", {"default": 2, "min": 0}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
😆
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.
The main functions this introduces:
Mainly, this is meant to be an extremely simple method to convert data types without needing a node for each type to be converted.