# Floating point calculation speed

**URL:** <https://discourse.nodered.org/t/floating-point-calculation-speed/12669>\
**Category:** General\
**Created:** [27 June 2019 16:58 UTC](https://discourse.nodered.org/t/floating-point-calculation-speed/12669 "2019-06-27T16:58:01Z")\
**Posts on this page:** 1\
**Showing post:** 24

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [10 July 2019 20:22 UTC](https://discourse.nodered.org/t/floating-point-calculation-speed/12669/24 "2019-07-10T20:22:49Z")

</div>

You probably should also avoid repeated calls to expensive math functions. For example, in the X-axis rotation matrix,

```auto
var cosx = Math.cos(Xrot);
var sinx = Math.sin(Xrot);
var Y1 = l1y*cosx-l1z*sinx;
var Z1 = l1z*cosx+l1y*sinx;

```

could be up to twice as fast as what you are doing now. It can be tempting (and more readable) to just code up the textbook equations, but if performance is an issue, think like a computer not a human.

---

_[View the full topic](https://discourse.nodered.org/t/floating-point-calculation-speed/12669)._
