user15277323
user15277323

Reputation:

In Haskell, how to get 0.03, instead of 3.0e-2?

Basically the title. I'm trying to display floats in a string, but the result ends up being "3.0e-2" (In the example of the float "0.03"). How do I get in decimal form in Haskell? Thanks to anyone who answers.

Upvotes: 3

Views: 84

Answers (1)

Fyodor Soikin
Fyodor Soikin

Reputation: 80765

For pretty formatting values of built-in types, use printf:

> printf "%f" (0.03 :: Float)
0.03

See the linked docs for a full explanation and all possible formatting options.

Upvotes: 5

Related Questions