-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArithmeticOperations.cs
More file actions
21 lines (20 loc) · 878 Bytes
/
ArithmeticOperations.cs
File metadata and controls
21 lines (20 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System.Reflection.Emit;
using JetBrains.Annotations;
namespace ILGeneratorExtensions
{
/// <summary>
/// Contains extension methods for performing arithmetic operations on integers and floating point values
/// </summary>
public static partial class ArithmeticOperations
{
/// <summary>
/// Negates the integer value on the top of the evaluation stack, with no overflow check
/// </summary>
/// <remarks>
/// If you need to check for overflow (as in the case of int.MinValue), you need to subtract the value from 0 instead.
/// </remarks>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator Negate(this ILGenerator generator) => generator.FluentEmit(OpCodes.Neg);
}
}