diff options
author | Guillermo Ramos | 2025-02-16 19:09:34 +0100 |
---|---|---|
committer | Guillermo Ramos | 2025-02-16 19:50:26 +0100 |
commit | 91588159234f7fe357a3fd0887367364a71e0df9 (patch) | |
tree | 4763ee048cf9441210a1c19b7a9c78f75844103e /front/src | |
parent | e006f43619f8763750baf98f14ffa095f19f2b2b (diff) | |
download | hiccup-91588159234f7fe357a3fd0887367364a71e0df9.tar.gz |
Elm round values
Diffstat (limited to 'front/src')
-rw-r--r-- | front/src/Main.elm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/front/src/Main.elm b/front/src/Main.elm index 47edd9d..4d39cb3 100644 --- a/front/src/Main.elm +++ b/front/src/Main.elm @@ -1,5 +1,6 @@ module Main exposing (..) +import Round import Browser import Html exposing (Html, button, div, input, text) import Html.Attributes exposing (max, min, step, type_, value) @@ -36,7 +37,7 @@ capitalDecoder = capitalStr : Capital -> String capitalStr { principal, interest } = - String.concat [ "{principal=", String.fromFloat principal, ", interest=", String.fromFloat interest, "}" ] + String.concat [ "{principal=", Round.round 2 principal, ", interest=", Round.round 2 interest, "}" ] type alias Quota = @@ -121,7 +122,7 @@ init : () -> ( Model, Cmd Msg ) init () = let simSpecs = - { principal = 300000.0, i1 = 2.1, years = 30 } + { principal = 200000.0, i1 = 1.621, years = 30 } req = runSimulation simSpecs @@ -238,14 +239,14 @@ specsView { principal, i1, years } = , onInput (UpdateSimSpecs Principal) ] [] - , text (String.fromFloat principal) + , text (Round.round 2 principal) ] , div [] [ text "Interest rate: " , input [ Html.Attributes.min "0" , Html.Attributes.max "100" - , value (String.fromFloat i1) + , value (Round.round 2 i1) , onInput (UpdateSimSpecs I1) ] [] @@ -269,7 +270,7 @@ specsView { principal, i1, years } = quotaView : Quota -> Html Msg quotaView { period, payed, pending_principal } = - div [] [ text (String.join "\t" [ String.fromInt period, capitalStr payed, String.fromFloat pending_principal ]) ] + div [] [ text (String.join "\t" [ String.fromInt period, capitalStr payed, Round.round 2 pending_principal ]) ] historyView : List Quota -> Html Msg |