Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Sqrt(float)

Returns square root of f (real number whose square equals f ).
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static float Sqrt(float f)

Parameters

Real number whose square root to calculate.

Returns

Type

Description

floatReal number whose square is
f
.

Remarks

When used with negative values, the output will be equal to NaN.

Examples

using UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour{ // The formula made famous by Pythagoras, also used internally by // Vector3.Distance and several other standard functions. float HypotenuseLength(float sideALength, float sideBLength) { return Mathf.Sqrt(sideALength * sideALength + sideBLength * sideBLength); }}