Skip to main content

round.go

round.go - Overview

This file provides a utility function for rounding floating-point numbers to a specified number of decimal places.

Detailed Documentation

Function: RoundToDecimals

Purpose: Rounds a float64 or float32 to a specified number of decimal places.

Parameters:

  • num (T): The number to round. Type T can be either float32 or float64.
  • decimals (int): The number of decimal places to round to.

Returns:

  • T: The rounded number, with the same type as the input num.

Getting Started Relevance: NO