Ruby Integer to_f function with example Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The to_f function in Ruby converts the value of the number as a float. If it does not fit in float, then it returns infinity. Syntax: number.to_f Parameter: The function takes the integer which is to be converted to float. Return Value: The function returns the float value of the number. Example #1: Ruby # Ruby program for to_f function # Initializing the number num1 = 5 num2 = 10 num3 = 1678 num4 = 1897.90 # Prints the int as float puts num1.to_f puts num2.to_f puts num3.to_f puts num4.to_f Output: 5.0 10.0 1678.0 1897.9 Example #2: Ruby # Ruby program for to_f function # Initializing the number num1 = 51 num2 = 10.78 num3 = 1690 num4 = 183 # Prints the int as float puts num1.to_f puts num2.to_f puts num3.to_f puts num4.to_f Output: 51.0 10.78 1690.0 183.0 Comment More infoAdvertise with us G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby | Loops (for, while, do..while, until) Looping is a fundamental concept in programming that allows for the repeated execution of a block of code based on a condition. Ruby, being a flexible and dynamic language, provides various types of loops that can be used to handle condition-based iterations. These loops simplify tasks that require 5 min read Ruby Programming Language Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. Ruby is a pure Object-Oriented language developed by Yukihiro Matsumoto. Everything in Ruby is an object except the blocks but there are replacements too for it i.e procs and lambda. The objective of Rubyâs develop 2 min read Ruby on Rails Introduction Ruby on Rails or also known as rails is a server-side web application development framework that is written in the Ruby programming language, and it is developed by David Heinemeier Hansson under the MIT License. It supports MVC(model-view-controller) architecture that provides a default structure f 6 min read Ruby on Rails Interview Questions And Answers Ruby on Rails, often shortened to Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is known for its ease of use and ability to build complex web applications quickly. It was created by David Heinemeier Hansson and was first released in 2004. Now, Over 3. 15+ min read Ruby - String split() Method with Examples split is a String class method in Ruby which is used to split the given string into an array of substrings based on a pattern specified. Here the pattern can be a Regular Expression or a string. If pattern is a Regular Expression or a string, str is divided where the pattern matches. Syntax: arr = s 2 min read Ruby Tutorial Ruby is a object-oriented, reflective, general-purpose, dynamic programming language. Ruby was developed to make it act as a sensible buffer between human programmers and the underlying computing machinery. It is an interpreted scripting language which means most of its implementations execute instr 6 min read Ruby | Data Types Data types in Ruby represents different types of data like text, string, numbers, etc. All data types are based on classes because it is a pure Object-Oriented language. There are different data types in Ruby as follows: NumbersBooleanStringsHashesArraysSymbols Numbers: Generally a number is defined 3 min read Ruby | Case Statement The case statement is a multiway branch statement just like a switch statement in other languages. It provides an easy way to forward execution to different parts of code based on the value of the expression. There are 3 important keywords which are used in the case statement: case: It is similar to 3 min read Hello World in Ruby Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. Hello World the program is the most basic and first program when we start a new programming language. This simply prints Hello World on the screen. Below is the program to write hello world". How to run a Ruby Prog 2 min read Ruby For Beginners Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. This article will cover its basic syntax and some basic programs. This article is divided into various sections for various topi 3 min read Like