From 5dfd55673ce05e24d9924eed59fc3e8513a9ebb3 Mon Sep 17 00:00:00 2001 From: Martinez Date: Tue, 22 Sep 2015 00:54:33 +0200 Subject: [PATCH] fix over.core.m.compare_float --- core/m.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/core/m.py b/core/m.py index fdbcbbc..6c75076 100644 --- a/core/m.py +++ b/core/m.py @@ -1,34 +1,27 @@ #! /usr/bin/env python3 # encoding: utf-8 -import sys - class compare_float: """ - Sets .lt, .eq or .gt iff A is less than, equal (within epsilon) or greather than B. + Sets .lt, .eq or .gt iff A is less than, equal or greather than B. """ - def __init__(self, A, B, epsilon=sys.float_info.epsilon): + def __init__(self, A, B, epsilon=1e-12): self.lt = False self.le = True self.eq = False self.ge = True self.gt = False - if A < B: + if A < (B - epsilon): self.lt = True - self.le = True self.ge = False - elif A > B: + elif A > (B + epsilon): self.gt = True self.le = False - self.ge = True if abs(A - B) < epsilon: self.eq = True - else: - self.le = False - self.ge = False # convenience self.less = self.lt