# Problem with "/ by zero"

**URL:** <https://forum.cloverdx.com/t/problem-with-by-zero/1091>\
**Category:** CloverDX Platform\
**Created:** [July 6, 2012, 12:00am UTC](https://forum.cloverdx.com/t/problem-with-by-zero/1091 "2012-07-06T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lwickenden](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@lwickenden](https://forum.cloverdx.com/u/lwickenden)\
**Post date:** [July 6, 2012, 12:00am UTC](https://forum.cloverdx.com/t/problem-with-by-zero/1091/1 "2012-07-06T00:00:00Z")

</div>

I am trying to divide the value of one column ($in.0.\_2012\_Buildings\_Local\_Ccy) by the value in another ($in.0.USD\_ROE) but I am running into the “/ by zero” error message. The reason for the division is to translate non-USD values into their USD equivalents.

Although most of the “$in.0.USD\_ROE” values are 1 (or greater than 1), some of the values in this column are less than 1 (e.g. 0.646, 0.7994) and I wonder whether that’s why I’m seeing the “/ by zero” message?

I’ve tried various approaches but none seem to fix the problem, for example:  
$out.0.buildings\_value = round(nvl($in.0.\_2012\_Buildings\_Local\_Ccy,0/$in.0.USD\_ROE));

$out.0.buildings\_value = (nvl($in.0.\_2012\_Buildings\_Local\_Ccy,0/$in.0.USD\_ROE));

$out.0.buildings\_value = round(nvl($in.0.\_2012\_Buildings\_Local\_Ccy,0)/$in.0.USD\_ROE);

$out.0.buildings\_value = ($in.0.\_2012\_Buildings\_Local\_Ccy/$in.0.USD\_ROE); (in this case I get an “unexpected null value” message instead of the “/ by zero” message).

Both columns are defined as “long”.

Could someone please tell me the correct expression to divide by a number that’s greater than 0 but less than 1.

Thanks,

Loretta

---

<div class="post-metadata">

**Author:** ![David\_Hlidek](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@David\_Hlidek](https://forum.cloverdx.com/u/David_Hlidek)\
**Post date:** [July 9, 2012, 8:41am UTC](https://forum.cloverdx.com/t/problem-with-by-zero/1091/2 "2012-07-09T08:41:12Z")

</div>

Hi Loretta,

If data types are “long”, then when data are read it is automatically rounded to “long” data type (which is integer number - so no digits after decimal point). Then 0.456 is rounded to 0 which causes problems with dividing.

Change “long” in metadata to “decimal” or “number” will solve your issue. See [http://doc.cloveretl.com/documentation/ … types.html](http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/data-types-and-record-types.html) for details.

See edge debug possibility to see actual data going to transformer: [http://doc.cloveretl.com/documentation/ … edges.html](http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/debug-edges.html)

---

<div class="post-metadata">

**Author:** ![lwickenden](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@lwickenden](https://forum.cloverdx.com/u/lwickenden)\
**Post date:** [July 9, 2012, 9:50pm UTC](https://forum.cloverdx.com/t/problem-with-by-zero/1091/3 "2012-07-09T21:50:00Z")

</div>

Hi Jaroslav,

Thank you for the very clear explanation.

Best regards,

Loretta
