How to get the smallest number greater than or equal to int in Ruby

2 Answers

0 votes
x = 8;
puts x.ceil 

x = 3.4
puts x.ceil

x = 3.5
puts x.ceil

x = 3.6
puts x.ceil

x = -7;
puts x.ceil 



   
#
# run:
# 
# 8
# 4
# 4
# 4
# -7
#

 



answered Oct 18, 2021 by avibootz
0 votes
x = -8;
puts x.ceil 

x = -3.4
puts x.ceil

x = -3.5
puts x.ceil

x = -3.6
puts x.ceil





   
#
# run:
# 
# -8
# -3
# -3
# -3
#

 



answered Oct 18, 2021 by avibootz
...