Poll: Was this article helpful for you?
You do not have permission to vote in this poll.
Yes
100.00%
1 100.00%
No
0%
0 0%
Total 1 vote(s) 100%
* You voted for this item. [Show Results]

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Floor and precisions in Ruby
#1
Example 1
Let's assume our number is 12.12 and we want to print the floor without any precision:


Quote:puts 12.12.floor


This will print 12 on the screen

Example 2
Let's assume our number is 12.12 and we want to print the floor with a precision of 1 decimal place:


Quote:puts 12.12.floor(1)


This will print 12.1 on the screen

Example 3
Let's assume our number is 12.12 and we want to print the floor with a precision of 2 decimal places:


Quote:puts 12.12.floor(2)


This will print 12.12 on the screen
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Everything you need to know about Ruby Qomplainerz 0 531 07-25-2023, 09:53 AM
Last Post: Qomplainerz
  Additions in Ruby Qomplainerz 0 1,576 03-14-2021, 10:13 AM
Last Post: Qomplainerz
  Subtractions in Ruby Qomplainerz 0 1,502 03-08-2021, 11:42 AM
Last Post: Qomplainerz
  Predecessor in Ruby Qomplainerz 0 1,604 02-28-2021, 10:31 AM
Last Post: Qomplainerz
  Successor in Ruby Qomplainerz 0 1,545 02-28-2021, 10:29 AM
Last Post: Qomplainerz
  Least common multiple in Ruby Qomplainerz 0 1,640 02-28-2021, 09:11 AM
Last Post: Qomplainerz
  Ceil and precisions in Ruby Qomplainerz 0 1,616 02-28-2021, 08:35 AM
Last Post: Qomplainerz
  Quotients and remainders in Ruby Qomplainerz 0 1,846 02-27-2021, 08:51 AM
Last Post: Qomplainerz
  Getting the currently installed Ruby version Qomplainerz 0 1,604 02-26-2021, 08:23 AM
Last Post: Qomplainerz
  Getting started with Ruby 3 Qomplainerz 0 1,891 02-26-2021, 07:34 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 3 Guest(s)