Click or drag to resize

ExtensionMethodsRoundToNearest Method (Single, Single)

Rounds a number where you can specify the precision of the rounding

Namespace:  DustProductions.Core
Assembly:  DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static float RoundToNearest(
	this float numToRound,
	float roundTo
)

Parameters

numToRound
Type: SystemSingle
The number being rounded
roundTo
Type: SystemSingle
The precision of the rounding (e.g. Passing in 5f will round to the nearest number divisible by 5f)

Return Value

Type: Single
A float that has been rounded to the nearest number divisible by roundTo

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Single. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also