# Need help with precision in python

**URL:** <https://forum.dynamobim.com/t/need-help-with-precision-in-python/30829>\
**Category:** Uncategorized\
**Created:** [January 17, 2019, 4:15pm UTC](https://forum.dynamobim.com/t/need-help-with-precision-in-python/30829 "2019-01-17T16:15:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schasfoortyoeri](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Schasfoortyoeri](https://forum.dynamobim.com/u/Schasfoortyoeri)\
**Post date:** [January 17, 2019, 4:15pm UTC](https://forum.dynamobim.com/t/need-help-with-precision-in-python/30829/1 "2019-01-17T16:15:15Z")

</div>

Hi all,

Im trying to calculate something and i want it to be precise.  
this is what i got, but it seems to not give me an outcome:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/593c5330ed2a893bd8e529d5738d65f5dcfd393f.png)

This is the pythoncode i m using:

> import clr  
> clr.AddReference(‘ProtoGeometry’)  
> from Autodesk.DesignScript.Geometry import \*  
> clr.AddReference(‘RevitServices’)  
> import RevitServices  
> from RevitServices.Persistence import DocumentManager  
> from RevitServices.Transactions import TransactionManager  
> import sys  
> sys.path.append(‘C:\Program Files (x86)\IronPython 2.7\Lib’)  
> from decimal import \*  
> #getcontext().rounding = ROUND\_HALF\_UP  
> from math import \*  
> #getcontext().prec = 7  
> getcontext().prec = 28
> 
> kop = IN[0]  
> voeg = IN[1]  
> koppenmaatDynamo = IN[2]  
> koppenmaatPython = Decimal(kop) + Decimal(voeg)  
> ftmm = 304.8
> 
> kop2 = Decimal(‘10.123456789123456789’)
> 
> OUT = koppenmaatDynamo, koppenmaatPython, kop2

if i calculate 10.1234567891234 + 100 it rounds the last digit.  
i m trying to sum them in python without the rounding.

any help is greatly appriciated, also if it isnt possible please let me know.

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [January 17, 2019, 4:25pm UTC](https://forum.dynamobim.com/t/need-help-with-precision-in-python/30829/2 "2019-01-17T16:25:18Z")

</div>

Try and have a look at this topic [Python wrong outcome because it rounds my float value](https://forum.dynamobim.com/t/python-wrong-outcome-because-it-rounds-my-float-value/30590?u=jonathan.olesen)

---

<div class="post-metadata">

**Author:** ![Schasfoortyoeri](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Schasfoortyoeri](https://forum.dynamobim.com/u/Schasfoortyoeri)\
**Post date:** [January 17, 2019, 5:31pm UTC](https://forum.dynamobim.com/t/need-help-with-precision-in-python/30829/3 "2019-01-17T17:31:26Z")

</div>

Thats my own topic 😛  
Then i didnt know about the python decimal module.  
It should be more precise than float?
