# Unit range question

**URL:** <https://forum.xod.io/t/unit-range-question/2934>\
**Category:** Uncategorized\
**Created:** [November 26, 2019, 9:13pm UTC](https://forum.xod.io/t/unit-range-question/2934 "2019-11-26T21:13:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertspark](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@robertspark](https://forum.xod.io/u/robertspark)\
**Post date:** [November 26, 2019, 9:13pm UTC](https://forum.xod.io/t/unit-range-question/2934/1 "2019-11-26T21:13:28Z")

</div>

I’ve noticed that the unit range is commonly 0-1 (zero to one)… so for instance an analog read node takes the read value and divides it by 1023 in order to remap the range from 0-1

I was wondering if there was not more merit in speeding up the math within the micro controllers by using multiply instead of divide?

> **[Speed of math operations (particularly division) on Arduino](https://forum.arduino.cc/t/speed-of-math-operations-particularly-division-on-arduino/90726)**
>
> We ran into some performance issues on a recent project and were curious as to how various operations affected execution time. The common wisdom is that division is slower than multiplication or the other standard operations. We looked around for...

i.e if you look at the analog read node:

> emitValue\<output\_VAL\>(ctx, ::analogRead(port) / 1023.);

it will perform divide every time it reads the analog port.

…

may I suggest maybe changing this node (and others similar to it) to maybe make use of multiply instead

where you define

> const float ADCon = 1 / 1023.0;

And then use:

> emitValue\<output\_VAL\>(ctx, ::analogRead(port) \* ADCon);

or something else?

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [November 27, 2019, 3:36pm UTC](https://forum.xod.io/t/unit-range-question/2934/2 "2019-11-27T15:36:44Z")

</div>

Hello! Interesting idea. However, I’m seriously doubt this applies to _compile-time constant_ multiplication and division. Modern compilers (GCC in case of XOD) are smart enough to choose the faster instrucion given that the value is known in advance.

If anyone can put an experiment with measurements which proves or rejects the hypothesis, it would be great.
