Elm Exactly
Results / elm-core /

StringFromNumberFloatTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.fromFloat` prints zero, positive, negative and small fractions in their
shortest form, and prints a whole-valued `Float` without a decimal point (`42.0` as `"42"`,
`0.0` as `"0"`).

Results

elm-0.19.1

passran in 38 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
zero: "0"
positive: "3.14"
negative: "-2.5"
small: "0.001"
integer_valued: "42"

elm-0.19.2

passran in 51 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
zero: "0"
positive: "3.14"
negative: "-2.5"
small: "0.001"
integer_valued: "42"

elm-0.19.3

passran in 43 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
zero: "0"
positive: "3.14"
negative: "-2.5"
small: "0.001"
integer_valued: "42"

lamdera-1.5.0

passran in 43 ms
Output
zero: "0"
positive: "3.14"
negative: "-2.5"
small: "0.001"
integer_valued: "42"

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/StringFromNumberFloatTest] in its title.

Source

The -- CHECK: lines give the expected output.

module StringFromNumberFloatTest exposing (main)
{-| `String.fromFloat` prints zero, positive, negative and small fractions in their
shortest form, and prints a whole-valued `Float` without a decimal point (`42.0` as `"42"`,
`0.0` as `"0"`).
-}
-- CHECK: zero: "0"
-- CHECK: positive: "3.14"
-- CHECK: negative: "-2.5"
-- CHECK: small: "0.001"
-- CHECK: integer_valued: "42"
import Html exposing (text)
main =
let
_ =
Debug.log "zero" (String.fromFloat 0.0)
_ =
Debug.log "positive" (String.fromFloat 3.14)
_ =
Debug.log "negative" (String.fromFloat -2.5)
_ =
Debug.log "small" (String.fromFloat 0.001)
_ =
Debug.log "integer_valued" (String.fromFloat 42.0)
in
text "done"