Skip to content

Instantly share code, notes, and snippets.

@ms5
ms5 / fuzzyequal.py
Last active August 29, 2015 14:02
Fuzzy compare of floats in python
'''
fuzzyequal: compare two floats with tolerance
float1: float value1
float2: float value2
tolerance: float tolerance applied while comparing value1 and value2
prec: int precision when comparing float (decimal places)
returns: bool (True, False)
'''
def fuzzyequal (float1, float2, tolerance=0.01, prec=4):