Last active
May 26, 2019 05:43
-
-
Save puripuri2100/475b95cf05a0c2b2999d333bb5ca456e to your computer and use it in GitHub Desktop.
小数点以下の桁数を揃える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let show-float-fix fl n = | |
let string = show-float fl in | |
let main-fl = | |
let n = round fl in | |
let fl-n = float n in | |
fl -. fl-n | |
in | |
let main-string = show-float main-fl in | |
let st-len = string-length main-string in | |
let-rec add-zero n = | |
if n < -1 then | |
` ` | |
else | |
`0` ^ add-zero (n - 1) | |
in | |
string ^ add-zero (n - st-len) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment