Removed trailing zeroes and point
This commit is contained in:
parent
6cada53cb0
commit
16aca9a66b
1 changed files with 2 additions and 2 deletions
|
@ -16,10 +16,10 @@ main = ioLoop
|
|||
precision = 5 :: Int
|
||||
|
||||
showRatio :: Int -> Rational -> String
|
||||
showRatio p r = (if (r < 0) then "-" else "") ++ prepoint_digits ++ "." ++ postpoint_digits
|
||||
showRatio p r = (if (r < 0) then "-" else "") ++ prepoint_digits ++ (if (length postpoint_digits > 0) then ("." ++ postpoint_digits) else "")
|
||||
where
|
||||
prepoint_digits = init . show . round . abs $ (r * 10)
|
||||
postpoint_digits = (take p) . (drop (length prepoint_digits)) . show . round . abs $ (r * 10^p)
|
||||
postpoint_digits = reverse .dropWhile (=='0') . reverse .(take p) . (drop (length prepoint_digits)) . show . round . abs $ (r * 10^p)
|
||||
|
||||
useResult (Right e) = (showRatio precision) . evaluate $ replaceVars e vars
|
||||
useResult (Left e) = show e
|
||||
|
|
Loading…
Reference in a new issue