Skip to content

Commit 02e9178

Browse files
add debug statement
1 parent f57dc45 commit 02e9178

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tunits/core/cython/frac.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
cimport cython
16-
from libc.math cimport floor as c_floor, pow as c_pow, fabs as c_fabs
16+
from libc.math cimport floor as c_floor, pow as c_pow
1717

1818
# A ratio that should always be canonicalized into least terms with the sign
1919
# on the numerator.
@@ -85,7 +85,9 @@ cpdef frac float_to_twelths_frac(a) except *:
8585

8686
cdef double d = float(a)
8787
cdef long long x = <long long>c_floor(12*d + 0.5)
88-
if c_fabs(12*d - x) > 1e-5:
88+
cdef double diff = 12*d - x
89+
if max(diff, -diff) > 1e-5:
90+
print(f'%.20f'%diff)
8991
raise ValueError("Not a twelfth.")
9092

9193
return frac_least_terms(x, 12)

0 commit comments

Comments
 (0)