Method: Flt::FormatBase#next_minus

Defined in:
lib/float-formats/classes.rb

#next_minusObject

Computes the previous adjacent floating point value. Accepts either a Value or a byte String. Returns a Value.



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/float-formats/classes.rb', line 236

def next_minus
  s,f,e = self.class.canonicalized(@sign,@significand,@exponent,true)
  return minus.next_plus.minus if s<0
  return self.next_plus.minus if e==:zero
  if e!=:nan
    if e == :infinity
      f = form_class.maximum_integral_significand
      e = form_class.radix_max_exp(:integral_significand)
    else
      f -= 1
      if f<form_class.minimum_normalized_integral_significand
        if e!=:denormal && e>form_class.radix_min_exp(:integral_significand)
          e -= 1
          f *= form_class.radix
        else
          if form_class.gradual_underflow?
            e = :denormal
          else
            e = :zero
          end
        end
      end
    end
  end
  form_class.new s, f, e
end