# decimal.Decimal in report only returns 1 decimal

**URL:** <https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 2, 2022, 11:07am UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707 "2022-03-02T11:07:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vipo](https://avatars.discourse-cdn.com/v4/letter/v/eada6e/32.png) [@vipo](https://forum.inductiveautomation.com/u/vipo)\
**Post date:** [March 2, 2022, 11:07am UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707/1 "2022-03-02T11:07:33Z")

</div>

I’m trying to use decimal.Decimal in report scripting, but it’s not returning what I expect:

IN REPORT:  
test = decimal.Decimal(72)/decimal.Decimal(7)  
returns 10.3

IN SCRIPT CONSOLE:  
print(decimal.Decimal(72)/decimal.Decimal(7))  
returns 10.28571428571428571428571429

Can someone explain the reason for this ?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 2, 2022, 3:21pm UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707/2 "2022-03-02T15:21:14Z")

</div>

How are you ‘confirming’ your return value? Text fields in reporting will round values for display.

---

<div class="post-metadata">

**Author:** ![vipo](https://avatars.discourse-cdn.com/v4/letter/v/eada6e/32.png) [@vipo](https://forum.inductiveautomation.com/u/vipo)\
**Post date:** [March 3, 2022, 11:09am UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707/3 "2022-03-03T11:09:57Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/2/f2f0630c204fa6bcb423e464bd568691564ac761.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 3, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707/4 "2022-03-03T17:57:10Z")

</div>

It’s working as I would expect on my end, even with different mechanism to create the decimal:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/b/6bbd0d7458f21b0c7bbc4701a2571ecf132e31b2.jpeg)

```python
	from java.math import BigDecimal, MathContext
	data["bigDecimal"] = BigDecimal(72).divide(BigDecimal(7), MathContext.DECIMAL128)
	
	import decimal
	data["decimal"] = decimal.Decimal(72) / decimal.Decimal(7) 
	
	data["double"] = 72.0 / 7

```

The number format of each example is set to force arbitrary precision:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/34043cc51a1fa3097a3bc9371353758e08b6b3e3.png)

---

<div class="post-metadata">

**Author:** ![vipo](https://avatars.discourse-cdn.com/v4/letter/v/eada6e/32.png) [@vipo](https://forum.inductiveautomation.com/u/vipo)\
**Post date:** [March 4, 2022, 1:03pm UTC](https://forum.inductiveautomation.com/t/decimal-decimal-in-report-only-returns-1-decimal/56707/5 "2022-03-04T13:03:51Z")

</div>

Thanks for those examples.  
Both “bigDecimal” and “double” work, but “decimal” just won’t work.

I made the exact same test as you, so I don’t know what’s going on.  
Anyways, I can make use of the other two.

thanks again.
