pythongosssss / ComfyUI-Custom-Scripts

Enhancements & experiments for ComfyUI, mostly focusing on UI features
MIT License
1.37k stars 104 forks source link

Math Expression xor issue #237

Closed Bocian-1 closed 1 month ago

Bocian-1 commented 2 months ago

Even with just 1^1 I get this error: `Error occurred when executing MathExpression|pysssss:

unsupported operand type(s) for ^: 'float' and 'float'` image

PS; I'd love to be able to use more logic functions in this node if possible, I've been able to simulate an and, but it's far from pretty

pythongosssss commented 1 month ago

Fixed xor a^b (everything was previously cast to a float, it now leaves ints as they are)

Additionally ive added:

Bitwise ops: a|b a&b ~a

Cast: int(a) - if you have a float but need to use a bitwise operator

Boolean ops (all return 1 or 0): a and b a or b not a

Comparison ops (all return 1 or 0): == != > >= < <=

Conditional: iif(value, a, b) - No lazy evaluation, if value is truthy a will be returned, else b

Hopefully that'll be of some use to you (assuming I didn't mess anything up 😅)