ruby - How to check if number has a decimal? -


i want check if given number contains ".5"

i'm dealing whole numbers , halves (0.5, 1, 1.5, etc).

% should work

variable % 1 != 0

check fiddle

edit: here rubyfiddle


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -