Float input values converted to text using Float.to_string() function, displaying exponentional values

Hello,

It seems that Liveview uses the Float.to_string() function when rendering a float into HTML. Consequence is that numbers > 999.0 are converted into exponential values. This is particularly problematic for form input fields:

Do you know what’s the best approach to overcome this? Use Decimals only for large numbers? Convert float to Decimals into Liveview templates?

Many thanks!

For your specific case: You never want to use float for monetary values.

For the general case I’d love to see phoenix default to non scientific notation, but I doubt that this can be changed easily without it be being a breaking change.

2 Likes