Sign Node

john's Avatar

john

08 Apr, 2023 08:14 AM

Attached is a very simple but occasionally useful node: sign.

Sign returns the sign of a number: -1 if the number is negative, +1 if the number is positive, or 0 if the number is 0 (or -0).

This comes in handy every now and then. It's not terribly hard to compute from scratch, but you do have to beware of those negative zeros which sometimes appear. So it's easier to copy paste this node than to reinvent that wheel each time. Most languages have this function. Now we do too.

Sign will be included in the upcoming 3.2 rev of my library - coming soon!

John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • sign_demo_screenshot.png 364 KB
  • sign_demo.ndbx.zip 9.15 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

17 Apr, 2025 07:02 PM
16 Apr, 2025 10:59 PM
16 Apr, 2025 10:02 AM
14 Apr, 2025 10:55 PM
14 Apr, 2025 10:18 PM

 

13 Apr, 2025 11:09 PM
10 Apr, 2025 11:30 PM
10 Apr, 2025 10:16 PM
10 Apr, 2025 10:02 PM
03 Apr, 2025 04:44 PM
30 Mar, 2025 02:09 AM