# How convert string value to float

**URL:** <https://forum.robotframework.org/t/how-convert-string-value-to-float/5666>\
**Category:** Robot Framework\
**Created:** [8 May 2023 11:11 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666 "2023-05-08T11:11:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [8 May 2023 11:11 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/1 "2023-05-08T11:11:21Z")

</div>

hi all,

im fetching string value ex:- x= 12.345  
in the same way im fetching another value say y= 12.34500

i need compare both value they should be equal but extra zero making it fail

please help me out to find solution

---

<div class="post-metadata">

**Author:** ![pekkaklarck](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/pekkaklarck/32/1019_2.png) [@pekkaklarck](https://forum.robotframework.org/u/pekkaklarck)\
**Post date:** [8 May 2023 12:40 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/2 "2023-05-08T12:40:10Z")

</div>

`Should Be Equal As Numbers` from BuiltIn automatically converts arguments to floats.

---

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [8 May 2023 13:20 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/3 "2023-05-08T13:20:15Z")

</div>

Thanks

I have tried should be equal to Numbers keyword but gives error.

The values are like x=16.442,300  
Another one y=16.442,3  
I have used ‘get text’ to fetch values

Error- can’t convert to floating point number : value error : could not convert string to float : 16.442,300

I have used parse also not worked

Can u help please

---

<div class="post-metadata">

**Author:** ![\_daryl](https://avatars.discourse-cdn.com/v4/letter/_/45deac/32.png) [@\_daryl](https://forum.robotframework.org/u/_daryl)\
**Post date:** [8 May 2023 15:00 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/4 "2023-05-08T15:00:38Z")

</div>

At a guess, you’ll probably need to strip out the “,” comma first (but I could be wrong)

---

<div class="post-metadata">

**Author:** ![Gautam](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@Gautam](https://forum.robotframework.org/u/Gautam)\
**Post date:** [8 May 2023 17:41 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/5 "2023-05-08T17:41:08Z")

</div>

\*\*\* Settings \*\*\*  
Library

\*\*\* Test Cases \*\*\*  
Compare String Values With Trailing Zeroes  
${x} Set Variable 12.34,5  
${y} Set Variable 12.34,500  
${x\_float} Evaluate float(“${x}”.replace(“,”, “”))  
${y\_float} Evaluate float(“${y}”.replace(“,”, “”))  
Should Be Equal As Numbers ${x\_float} ${y\_float}

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [9 May 2023 04:55 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/6 "2023-05-09T04:55:33Z")

</div>

Hi pavan,

> [@pavan](#):
>
> 16.442,300

What’s the source of this number? The reason I ask → [Decimal separator - Wikipedia](https://en.wikipedia.org/wiki/Decimal_separator)

Before you mess with the numbers you should know which of the `.` or `,` is the decimal separator and which is thousand separator?

Dave.

---

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [9 May 2023 05:34 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/7 "2023-05-09T05:34:08Z")

</div>

I have fetched number from bar chart(graph)

---

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [9 May 2023 06:15 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/8 "2023-05-09T06:15:18Z")

</div>

Thank you all for your valuable time got solution

---

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [9 May 2023 06:26 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/9 "2023-05-09T06:26:57Z")

</div>

Thank you so much got it right

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [9 May 2023 10:20 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/10 "2023-05-09T10:20:09Z")

</div>

Hi pavan,

> [@pavan](#):
>
> I have fetched number from bar chart(graph)

I actually meant what country did the source data come from? I see you solved it already 👍

Dave.

---

<div class="post-metadata">

**Author:** ![pavan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@pavan](https://forum.robotframework.org/u/pavan)\
**Post date:** [9 May 2023 10:34 UTC](https://forum.robotframework.org/t/how-convert-string-value-to-float/5666/11 "2023-05-09T10:34:14Z")

</div>

Hi dave

I thought something else but got it.

Than you for time so much
