Cos 90 degree (1.5708 radian) = 6.123233 ??

EL's Avatar


11 Mar, 2020 02:37 PM

Hello! cos 90 degree should be 0, isn't it?
The screencap and nodebox file is attached for reference.

  1. 1 Posted by EL on 11 Mar, 2020 02:39 PM

    EL's Avatar

    Attached nodebox source file for your test.

  2. 2 Posted by EL on 11 Mar, 2020 03:01 PM

    EL's Avatar

    Oh, my bad, 6.123233... E-17 == 0.00000000000000006123233... which is basically 0
    Please close the topic.

  3. Support Staff 3 Posted by john on 11 Mar, 2020 06:48 PM

    john's Avatar


    I'm glad you shared this. I have hit this exact issue before and it was bewildering until I figured it out.

    The problem is numerical precision - a problem common to all languages and computers in general - not just NodeBox. It pops up all the time in places you wouldn't expect. And it can play havoc with your code!

    As you said, "6.123233... E-17" is basically 0. But it's not EXACTLY zero. So if you are relying on a compare node to test whether this value is zero, compare will return a false. After that, bad things may happen.

    I have a fix for this.

    The next release of my node library includes a new node (actually a subnetwork) called precision. I am attaching it here in a demo file (see screenshot).

    Precision is very simple. It returns an altered version of any number you pass to it, trimmed to as many digits as you wish. If you specify a zero, it will return an integer (using the round node); otherwise it will return a float.

    Note that it is not just changing the format. It is changing the actual value of the number.

    Whenever I am doing calculations that can produce infinitesimal values (like cos), I routinely pass the results through this precision node before doing any divisions or compares. You can set the precision of cos(90 degrees) to anything up to 15 digits to make sure values like this will be true zeroes, not "almost zeroes". In practice, 4 or 5 digits is good enough for most calculations.

    Hope that helps!


Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • Screenshot_2020-03-11_at_10.19.41_PM.png 574 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


? 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

29 May, 2024 05:47 AM
29 May, 2024 05:15 AM
29 May, 2024 05:12 AM
28 May, 2024 07:37 PM
25 May, 2024 11:52 AM


24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
14 May, 2024 01:29 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM