Ruby | Vector round() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The round() is an inbuilt method in Ruby returns a new vector with entries rounded to the given precision Syntax: vec1.round() Parameters: The function accepts a single parameter Return Value: It returns a new vector with entries rounded to the given precision Example 1: Ruby # Ruby program for round() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1.145332, 2.932423, 3.1332445] # Prints vector rounded to given precision puts vec1.round(3) Output: Vector[1.145, 2.932, 3.133] Example 2: Ruby # Ruby program for round() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1.145332, 2.932423, 3.1332445] # Prints vector rounded to given precision puts vec1.round(0) Output: Vector[1, 3, 3] Comment More infoAdvertise with us Next Article Ruby | Vector r() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads Ruby | Vector r() function The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector r() function The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector r() function The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector norm() function The norm() is an inbuilt method in Ruby returns the pythagorean distance of the vector. Syntax: vec1.norm() Parameters: The function accepts no parameter Return Value: It pythagorean distance of the vector Example 1: Ruby # Ruby program for norm() method in Vector # Include matrix require "matr 1 min read Ruby | Vector norm() function The norm() is an inbuilt method in Ruby returns the pythagorean distance of the vector. Syntax: vec1.norm() Parameters: The function accepts no parameter Return Value: It pythagorean distance of the vector Example 1: Ruby # Ruby program for norm() method in Vector # Include matrix require "matr 1 min read Ruby | Vector norm() function The norm() is an inbuilt method in Ruby returns the pythagorean distance of the vector. Syntax: vec1.norm() Parameters: The function accepts no parameter Return Value: It pythagorean distance of the vector Example 1: Ruby # Ruby program for norm() method in Vector # Include matrix require "matr 1 min read Like