# Python float division, then binding, returns rounded int

**URL:** <https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716>\
**Category:** Ignition\
**Created:** [September 18, 2018, 3:35pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716 "2018-09-18T15:35:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 18, 2018, 3:35pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716/1 "2018-09-18T15:35:09Z")

</div>

My code: [code]  
price = system.db.runNamedQuery(‘Costing/FabricPricing’, params)  
if qty \>= 15:  
price = float(price)/2  
event.source.parent.getComponent(‘Price 3’).floatValue = price

[/code]

the price returned in this situation is $225, so divided by two will be a float value of 112.50, but it always comes out as 113? Every way I’ve tried always comes out to 113. I have the decimal format configured to $#,##0.00  
Any ideas on the culprit?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 18, 2018, 3:38pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716/2 "2018-09-18T15:38:02Z")

</div>

Float the 2 as well.  
price = float(price)/float(2)  
print price

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 18, 2018, 3:39pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716/3 "2018-09-18T15:39:26Z")

</div>

I already tried that, works in the console but not after the binding. still 113.00

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 18, 2018, 3:43pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716/4 "2018-09-18T15:43:56Z")

</div>

Do you have the number type on the control set to float?  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/86bf43c8bfd8ec3984030428eb7b9dd353f5743e.PNG)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 18, 2018, 3:45pm UTC](https://forum.inductiveautomation.com/t/python-float-division-then-binding-returns-rounded-int/19716/5 "2018-09-18T15:45:36Z")

</div>

Smack to the head. I didn’t see that dropdown, figured it would set it to float when binding to .floatValue. Thanks
