I have a sanitised string I want to evaluate using ruby eval. The string may contain any simple arithmetic formula, like '44/5'.
The problem is that the result of eval('44/5')
will be 8 (instead of 8.8).
It happens as a part of evaluating (because 1.0*eval('44/5')
gives 8.0).
I didn't find any extra parameter for eval to manage it.
I even tried to prepend or wrap the string to convert it to:
'0.0+44/5'
or
'1.0*(44/5)'
But it still doesn't give me 8.8.
eval('44.0/5')
gives me the desired result but I don't want to insert anything inside the string (I am ready just to wrap it if necessary).
Any idea how can I solve the problem?