Int to real conversion - to_real() function

In the GitHub issue for integer division there was a proposal to have a to_real function that would convert ints to reals. It seems this never got implemented, so I am just wondering if that was intentional or if there is a preferred workaround for converting ints to reals and thus e.g. avoid warnings about division when I need a real division of values that are integer (I iterate over integers and then need fractions formed by those integers).

Tagging @nhuurre who implemented the integer division…

Thanks for any hints

The easiest workaround is to multiply by 1.0. As far as I known division is the only operation that does not coerce int to real automatically so I didn’t think a to_real was necessary.

3 Likes