Reputation: 11
I'm trying to compute for a value using Evaluate keyword and it seems not storing the exact whole numeric numbers in the variable ${C1} but it seems to return the exact values I want as per log file.
Here's my sample code.
${C1} Evaluate 1.025**${C_IP_Years_Between}
Here's the log:
${C1} = BuiltIn . Evaluate 1.025**${C_IP_Years_Between}
Documentation:
Evaluates the given expression in Python and returns the results.
Start / End / Elapsed: 20180413 21:09:18.343 / 20180413 21:09:18.377 / 00:00:00.034
21:09:18.345 TRACE Arguments: [ '1.025**11' ]
21:09:18.376 TRACE Return: 1.3120866578012655
21:09:18.377 INFO ${C1} = 1.3120866578
How can I be able to use the whole values being returned above (e.g. 1.3120866578012655)
Upvotes: 1
Views: 1319
Reputation: 385970
The robot variable ${C1}
is a float, so it retains all of the precision. The log statement is simply not showing all of the digits.
You can see all of the digits if you explicitly convert the value to a string. In the following example, the test should pass:
*** Variables ***
${C_IP_Years_Between} 11
*** Test Cases ***
Example
${C1}= Evaluate 1.025**${C_IP_Years_Between}
${C1f}= Evaluate '{0:.16f}'.format($c1)
Should be equal as strings ${C1f} 1.3120866578012655
Upvotes: 1