docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method mad

    mad(int, int, int)

    Returns the result of a multiply-add operation (a * b + c) on 3 int values.

    Declaration
    public static int mad(int a, int b, int c)
    Parameters
    Type Name Description
    int a

    First value to multiply.

    int b

    Second value to multiply.

    int c

    Third value to add to the product of a and b.

    Returns
    Type Description
    int

    The multiply-add of the inputs.

    mad(int2, int2, int2)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int2 vectors.

    Declaration
    public static int2 mad(int2 a, int2 b, int2 c)
    Parameters
    Type Name Description
    int2 a

    First value to multiply.

    int2 b

    Second value to multiply.

    int2 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    int2

    The componentwise multiply-add of the inputs.

    mad(int3, int3, int3)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int3 vectors.

    Declaration
    public static int3 mad(int3 a, int3 b, int3 c)
    Parameters
    Type Name Description
    int3 a

    First value to multiply.

    int3 b

    Second value to multiply.

    int3 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    int3

    The componentwise multiply-add of the inputs.

    mad(int4, int4, int4)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 int4 vectors.

    Declaration
    public static int4 mad(int4 a, int4 b, int4 c)
    Parameters
    Type Name Description
    int4 a

    First value to multiply.

    int4 b

    Second value to multiply.

    int4 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    int4

    The componentwise multiply-add of the inputs.

    mad(uint, uint, uint)

    Returns the result of a multiply-add operation (a * b + c) on 3 uint values.

    Declaration
    public static uint mad(uint a, uint b, uint c)
    Parameters
    Type Name Description
    uint a

    First value to multiply.

    uint b

    Second value to multiply.

    uint c

    Third value to add to the product of a and b.

    Returns
    Type Description
    uint

    The multiply-add of the inputs.

    mad(uint2, uint2, uint2)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint2 vectors.

    Declaration
    public static uint2 mad(uint2 a, uint2 b, uint2 c)
    Parameters
    Type Name Description
    uint2 a

    First value to multiply.

    uint2 b

    Second value to multiply.

    uint2 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    uint2

    The componentwise multiply-add of the inputs.

    mad(uint3, uint3, uint3)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint3 vectors.

    Declaration
    public static uint3 mad(uint3 a, uint3 b, uint3 c)
    Parameters
    Type Name Description
    uint3 a

    First value to multiply.

    uint3 b

    Second value to multiply.

    uint3 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    uint3

    The componentwise multiply-add of the inputs.

    mad(uint4, uint4, uint4)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 uint4 vectors.

    Declaration
    public static uint4 mad(uint4 a, uint4 b, uint4 c)
    Parameters
    Type Name Description
    uint4 a

    First value to multiply.

    uint4 b

    Second value to multiply.

    uint4 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    uint4

    The componentwise multiply-add of the inputs.

    mad(long, long, long)

    Returns the result of a multiply-add operation (a * b + c) on 3 long values.

    Declaration
    public static long mad(long a, long b, long c)
    Parameters
    Type Name Description
    long a

    First value to multiply.

    long b

    Second value to multiply.

    long c

    Third value to add to the product of a and b.

    Returns
    Type Description
    long

    The multiply-add of the inputs.

    mad(ulong, ulong, ulong)

    Returns the result of a multiply-add operation (a * b + c) on 3 ulong values.

    Declaration
    public static ulong mad(ulong a, ulong b, ulong c)
    Parameters
    Type Name Description
    ulong a

    First value to multiply.

    ulong b

    Second value to multiply.

    ulong c

    Third value to add to the product of a and b.

    Returns
    Type Description
    ulong

    The multiply-add of the inputs.

    mad(float, float, float)

    Returns the result of a multiply-add operation (a * b + c) on 3 float values.

    Declaration
    public static float mad(float a, float b, float c)
    Parameters
    Type Name Description
    float a

    First value to multiply.

    float b

    Second value to multiply.

    float c

    Third value to add to the product of a and b.

    Returns
    Type Description
    float

    The multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(float2, float2, float2)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float2 vectors.

    Declaration
    public static float2 mad(float2 a, float2 b, float2 c)
    Parameters
    Type Name Description
    float2 a

    First value to multiply.

    float2 b

    Second value to multiply.

    float2 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    float2

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(float3, float3, float3)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float3 vectors.

    Declaration
    public static float3 mad(float3 a, float3 b, float3 c)
    Parameters
    Type Name Description
    float3 a

    First value to multiply.

    float3 b

    Second value to multiply.

    float3 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    float3

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(float4, float4, float4)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 float4 vectors.

    Declaration
    public static float4 mad(float4 a, float4 b, float4 c)
    Parameters
    Type Name Description
    float4 a

    First value to multiply.

    float4 b

    Second value to multiply.

    float4 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    float4

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(double, double, double)

    Returns the result of a multiply-add operation (a * b + c) on 3 double values.

    Declaration
    public static double mad(double a, double b, double c)
    Parameters
    Type Name Description
    double a

    First value to multiply.

    double b

    Second value to multiply.

    double c

    Third value to add to the product of a and b.

    Returns
    Type Description
    double

    The multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(double2, double2, double2)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double2 vectors.

    Declaration
    public static double2 mad(double2 a, double2 b, double2 c)
    Parameters
    Type Name Description
    double2 a

    First value to multiply.

    double2 b

    Second value to multiply.

    double2 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    double2

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(double3, double3, double3)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double3 vectors.

    Declaration
    public static double3 mad(double3 a, double3 b, double3 c)
    Parameters
    Type Name Description
    double3 a

    First value to multiply.

    double3 b

    Second value to multiply.

    double3 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    double3

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    mad(double4, double4, double4)

    Returns the result of a componentwise multiply-add operation (a * b + c) on 3 double4 vectors.

    Declaration
    public static double4 mad(double4 a, double4 b, double4 c)
    Parameters
    Type Name Description
    double4 a

    First value to multiply.

    double4 b

    Second value to multiply.

    double4 c

    Third value to add to the product of a and b.

    Returns
    Type Description
    double4

    The componentwise multiply-add of the inputs.

    Remarks

    When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)