Getting non-exponential version of float in Elixir?

Elixir Output: 3.5e-4

I want to show: 0.00035

Is there a way to restrict Elixir to output a non-exponential float version?

+3


source to share


1 answer


Typically, if you want precise control over the output, you need to use the underlying erlang library io:format

.

Erlang io format

It is somewhat unique, although it more or less works like printf or sprintf in other languages. If you are more familiar with these functions, there is an Elixir library that translates for you.



https://github.com/parroty/exprintf

The Float.to_string function is what is used to print floats, as far as I can tell, there is no way to override the format used.

+1


source







All Articles