mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 10:37:04 -04:00 
			
		
		
		
	Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
		
			
				
	
	
		
			27 lines
		
	
	
		
			622 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			622 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| 
 | |
| namespace API.Extensions;
 | |
| 
 | |
| public static class DoubleExtensions
 | |
| {
 | |
|     private const float Tolerance = 0.001f;
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Used to compare 2 floats together
 | |
|     /// </summary>
 | |
|     /// <param name="a"></param>
 | |
|     /// <param name="b"></param>
 | |
|     /// <returns></returns>
 | |
|     public static bool Is(this double a, double? b)
 | |
|     {
 | |
|         if (!b.HasValue) return false;
 | |
|         return Math.Abs((float) (a - b)) < Tolerance;
 | |
|     }
 | |
| 
 | |
|     public static bool IsNot(this double a, double? b)
 | |
|     {
 | |
|         if (!b.HasValue) return false;
 | |
|         return Math.Abs((float) (a - b)) > Tolerance;
 | |
|     }
 | |
| }
 |