How convert string value to float

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

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

1 Like

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

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

*** 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}

Hi pavan,

What’s the source of this number? The reason I ask → Decimal separator - Wikipedia

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

Dave.

I have fetched number from bar chart(graph)

Thank you all for your valuable time got solution

1 Like

Thank you so much got it right

1 Like

Hi pavan,

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

Dave.

Hi dave

I thought something else but got it.

Than you for time so much

1 Like