# chgsign

> Change the sign of x based on the most significant bit of y [msb(y)? -x: x].

## Definition

* **Type:** Method
* **Namespace:** [Unity.Mathematics](/engine/6000.7/script-reference/unity/mathematics.md)
* **Assembly:** UnityEngine.MathematicsModule

## chgsign(float, float)

Change the sign of x based on the most significant bit of y \[msb(y) ? -x : x].

```csharp
public static float chgsign(float x, float y)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The single precision float to change the sign.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The single precision float used to test the most significant bit.

### Returns

| Type                                                          | Description                             |
| ------------------------------------------------------------- | --------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | Returns x with changed sign based on y. |

## chgsign(float2, float2)

Change the sign of components of x based on the most significant bit of components of y \[msb(y) ? -x : x].

```csharp
public static float2 chgsign(float2 x, float2 y)
```

### Parameters

**** (\[float2]\(/engine/6000.7/script-reference/unity/mathematics/float2)): The single precision float vector to change the sign.**** (\[float2]\(/engine/6000.7/script-reference/unity/mathematics/float2)): The single precision float vector used to test the most significant bit.

### Returns

| Type                                                                  | Description                                           |
| --------------------------------------------------------------------- | ----------------------------------------------------- |
| [float2](/engine/6000.7/script-reference/unity/mathematics/float2.md) | Returns vector x with changed sign based on vector y. |

## chgsign(float3, float3)

Change the sign of components of x based on the most significant bit of components of y \[msb(y) ? -x : x].

```csharp
public static float3 chgsign(float3 x, float3 y)
```

### Parameters

**** (\[float3]\(/engine/6000.7/script-reference/unity/mathematics/float3)): The single precision float vector to change the sign.**** (\[float3]\(/engine/6000.7/script-reference/unity/mathematics/float3)): The single precision float vector used to test the most significant bit.

### Returns

| Type                                                                  | Description                                           |
| --------------------------------------------------------------------- | ----------------------------------------------------- |
| [float3](/engine/6000.7/script-reference/unity/mathematics/float3.md) | Returns vector x with changed sign based on vector y. |

## chgsign(float4, float4)

Change the sign of components of x based on the most significant bit of components of y \[msb(y) ? -x : x].

```csharp
public static float4 chgsign(float4 x, float4 y)
```

### Parameters

**** (\[float4]\(/engine/6000.7/script-reference/unity/mathematics/float4)): The single precision float vector to change the sign.**** (\[float4]\(/engine/6000.7/script-reference/unity/mathematics/float4)): The single precision float vector used to test the most significant bit.

### Returns

| Type                                                                  | Description                                           |
| --------------------------------------------------------------------- | ----------------------------------------------------- |
| [float4](/engine/6000.7/script-reference/unity/mathematics/float4.md) | Returns vector x with changed sign based on vector y. |
