Ruby Integer size() function with example Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The size() function in Ruby returns the number of bytes in the machine representation of int. Syntax: number.size Parameter: The function takes the integer whose number of bytes is returned. Return Value: The function returns the number of bytes. Example #1: Ruby # Ruby program for size() function # Initializing the numbers num1 = 18 num2 = 2**1000 num3 = 2**19 num4 = 5**100 # Printing the size value puts num1.size puts num2.size puts num3.size puts num4.size Output: 8 126 8 30 Example #2: Ruby # Ruby program for size() function # Initializing the numbers num1 = 18 num2 = 5**1000 num3 = 19**19 num4 = 12**100 # Printing the number # bytes used puts num1.size puts num2.size puts num3.size puts num4.size Output: 8 291 11 45 Comment More infoAdvertise with us Next Article Ruby Integer size() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer to_s function with example The to_s function in Ruby returns a string containing the place-value representation of int with radix base (between 2 and 36). If no base is provided in the parameter then it assumes the base to be 10 and returns. Syntax: number.to_s(base) Parameter: The function takes the number and a base to whi 1 min read Ruby Integer to_r function with example The to_r function in Ruby converts the value of the number to a rational. Syntax: number.to_r Parameter: The function takes the number which is to be converted to a rational number. Return Value: The function returns the rational number. Example #1: Ruby # Ruby program for to_r function # Initializi 1 min read Ruby Integer to_f function with example 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: 1 min read Ruby Integer gcd() function with example The gcd() function in Ruby returns the gcd of two numbers. GCD signifies the greatest common divisor which divides both the numbers. Syntax: number1.gcd(number2) Parameter: The function requires two numbers whose gcd is to be returned. Return Value: The function returns the gcd of two numbers Exampl 1 min read Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Like