@@ -125,7 +125,6 @@ module Float::Printer::Grisu3
125
125
# Conceptually rest ~= too_high - buffer
126
126
# We need to do the following tests in this order to avoid over- and
127
127
# underflows.
128
- _invariant rest <= unsafe_interval
129
128
while (
130
129
rest < small_distance && # Negated condition 1
131
130
unsafe_interval - rest >= ten_kappa && # Negated condition 2
@@ -199,9 +198,6 @@ module Float::Printer::Grisu3
199
198
# imprecision.
200
199
def digit_gen (low : DiyFP , w : DiyFP , high : DiyFP , buffer_p) : {Bool , Int32 , Int32 }
201
200
buffer = buffer_p.to_slice(128 )
202
- _invariant low.exp == w.exp && w.exp == high.exp
203
- _invariant low.frac + 1 <= high.frac - 1
204
- _invariant CachedPowers ::MIN_TARGET_EXP <= w.exp && w.exp <= CachedPowers ::MAX_TARGET_EXP
205
201
# low, w and high are imprecise, but by less than one ulp (unit in the last
206
202
# place).
207
203
# If we remove (resp. add) 1 ulp from low (resp. high) we are certain that
@@ -245,7 +241,6 @@ module Float::Printer::Grisu3
245
241
while kappa > 0
246
242
digit = integrals / divisor
247
243
# pp [digit, kappa]
248
- _invariant digit <= 9
249
244
buffer[length] = 48 _u8 + digit
250
245
length += 1
251
246
integrals %= divisor
@@ -273,15 +268,11 @@ module Float::Printer::Grisu3
273
268
# data (like the interval or 'unit'), too.
274
269
# Note that the multiplication by 10 does not overflow, because w.e >= -60
275
270
# and thus one.e >= -60.
276
- _invariant one.exp >= -60
277
- _invariant fractionals < one.frac
278
- _invariant 0xFFFFFFFFFFFFFFFF / 10 >= one.frac
279
271
loop do
280
272
fractionals *= 10
281
273
unit *= 10
282
274
unsafe_interval = DiyFP .new(unsafe_interval.frac * 10 , unsafe_interval.exp)
283
275
digit = (fractionals >> - one.exp).to_i
284
- _invariant digit <= 9
285
276
buffer[length] = 48 _u8 + digit
286
277
length += 1
287
278
fractionals &= one.frac - 1
@@ -317,7 +308,6 @@ module Float::Printer::Grisu3
317
308
# boundary_minus and boundary_plus will round to v when convert to a float.
318
309
# Grisu3 will never output representations that lie exactly on a boundary.
319
310
boundaries = IEEE .normalized_boundaries(v)
320
- _invariant boundaries[:plus ].exp == w.exp
321
311
322
312
ten_mk, mk = CachedPowers .get_cached_power_for_binary_exponent(w.exp)
323
313
@@ -331,7 +321,6 @@ module Float::Printer::Grisu3
331
321
# In other words: let f = scaled_w.f() and e = scaled_w.e(), then
332
322
# (f-1) * 2^e < w*10^k < (f+1) * 2^e
333
323
scaled_w = w * ten_mk
334
- _invariant scaled_w.exp == boundaries[:plus ].exp + ten_mk.exp + DiyFP ::SIGNIFICAND_SIZE
335
324
336
325
# In theory it would be possible to avoid some recomputations by computing
337
326
# the difference between w and boundary_minus/plus (a power of 2) and to
@@ -352,12 +341,4 @@ module Float::Printer::Grisu3
352
341
decimal_exponent = - mk + kappa
353
342
return result, decimal_exponent, length
354
343
end
355
-
356
- private macro _invariant (exp , file = __FILE__ , line = __LINE__ )
357
- {% if ! flag?(:release ) % }
358
- unless {{exp}}
359
- raise " Assertion Failed #{ {{file}} } :#{ {{line}} } "
360
- end
361
- {% end % }
362
- end
363
344
end
0 commit comments