Last active
November 19, 2021 01:05
-
-
Save nashirox/c1e6c464f65d466aa83b220521732aa5 to your computer and use it in GitHub Desktop.
小数点以下の桁数を取得
This file contains hidden or 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
def digits_after_decimal_point(val) | |
return unless val.is_a?(Numeric) | |
digits = 0 | |
while(val != val.to_i) | |
digits += 1 | |
val *= 10 | |
end | |
digits | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample