Fix to allow negative Values

This commit is contained in:
Christian 2022-05-04 16:19:57 +02:00
parent ad1fddf495
commit 7501cf7781

View File

@ -9,12 +9,21 @@ import Http exposing (..)
-- Please note that only 0 are added. The number will not be shortend!
addLeadingZero : Int -> Int -> String
addLeadingZero number length =
let
num_str = String.fromInt number
in
(String.fromList <| List.repeat (length - String.length num_str) '0'
)
++ num_str
if number >= 0 then
let
num_str = String.fromInt number
in
(String.fromList <| List.repeat (length - String.length num_str) '0'
)
++ num_str
else
let
num_str = String.fromInt <| 0-number
in
"-" ++
(String.fromList <| List.repeat (length - String.length num_str) '0'
)
++ num_str
-- Get the value at a given position in a List.