Fix to allow negative Values
This commit is contained in:
parent
ad1fddf495
commit
7501cf7781
@ -9,12 +9,21 @@ import Http exposing (..)
|
|||||||
-- Please note that only 0 are added. The number will not be shortend!
|
-- Please note that only 0 are added. The number will not be shortend!
|
||||||
addLeadingZero : Int -> Int -> String
|
addLeadingZero : Int -> Int -> String
|
||||||
addLeadingZero number length =
|
addLeadingZero number length =
|
||||||
let
|
if number >= 0 then
|
||||||
num_str = String.fromInt number
|
let
|
||||||
in
|
num_str = String.fromInt number
|
||||||
(String.fromList <| List.repeat (length - String.length num_str) '0'
|
in
|
||||||
)
|
(String.fromList <| List.repeat (length - String.length num_str) '0'
|
||||||
++ num_str
|
)
|
||||||
|
++ 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.
|
-- Get the value at a given position in a List.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user