# How to convert the decimal number to integer in robot framework

**URL:** <https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114>\
**Category:** Robot Framework\
**Created:** [3 April 2024 11:31 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114 "2024-04-03T11:31:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samta](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@samta](https://forum.robotframework.org/u/samta)\
**Post date:** [3 April 2024 11:31 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114/1 "2024-04-03T11:31:57Z")

</div>

Hi,  
I tried to convert Decimal(‘848.000000000000000000’) number to integer and getting the error message like “AttributeError: ‘int’ object has no attribute ‘lower’”

Code in Robot framework

${result}[${rowno}][7]= Decimal(‘848.000000000000000000’)  
${Query\_Description} = Set Variable ${result}[${rowno}][7]  
${KL1}= run keyword and continue on failure convert to integer ${Query\_Description}  
log to console The Mesurement Value ${KL1}

Getting the error message like "  
AttributeError: ‘int’ object has no attribute ‘lower’

 ![integer_issue](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/c/c19ae22142727e2e1085973a0fa6f5a482148259.png)  
 ![Integer_issue1](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/f/f52e0e5d8d9f33735f299a8d1a1813914b94e667.png)

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [3 April 2024 13:20 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114/2 "2024-04-03T13:20:20Z")

</div>

```robotframework
***Settings***
library foo.py
***Test Cases***
Test Case 1
  ${val}= Get Dec
  ${KL1}= run keyword and continue on failure convert to integer ${val}
  log to console The Mesurement Value ${KL1}

```

```python
from decimal import Decimal
def get_dec():
    return Decimal("848.000000000000000000")

```

This works and logs out 848 as it should … Your issue is most likely somewhere else outside of your shared code. I’d start by opening log.html and seeing what exact keyword is triggering that failure. Its way more present there than in the console.

---

<div class="post-metadata">

**Author:** ![Pramesh](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@Pramesh](https://forum.robotframework.org/u/Pramesh)\
**Post date:** [3 April 2024 13:52 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114/3 "2024-04-03T13:52:01Z")

</div>

Hello @samta,

As rasjani said, the issue might be coming from somewhere else. For example, the FOR loop that you have implemented seems bit off. Also, rasjani has provided a good example but here is one basic example using RF builtin:

```
Convert to integer
    ${number} Set Variable 848.000000000000000000
    ${KL1} run keyword and continue on failure convert to number ${number} 0
    log to console Converted floating point value is ${KL1}
    ${KL2} run keyword and continue on failure convert to integer ${KL1}
    log to console Converted integer value is ${KL2}

```

The result is:  
…Converted floating point value is 848.0  
…Converted integer value is 848  
Convert to integer | PASS |

---

<div class="post-metadata">

**Author:** ![samta](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@samta](https://forum.robotframework.org/u/samta)\
**Post date:** [3 April 2024 22:50 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114/4 "2024-04-03T22:50:28Z")

</div>

Thanks @Pramesh for your help. Now my code is working fine.  
I am using for loop to get all measurement value from SQL query:  
 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/3/3f4f9e55108472a730416f6befda56a1402414b3.png)

---

<div class="post-metadata">

**Author:** ![samta](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@samta](https://forum.robotframework.org/u/samta)\
**Post date:** [3 April 2024 22:52 UTC](https://forum.robotframework.org/t/how-to-convert-the-decimal-number-to-integer-in-robot-framework/7114/5 "2024-04-03T22:52:03Z")

</div>

Thanks @rasjani for your help to clear the basic concept for integer. It helps me to run my code.
