Method: Flt::FormatBase#next_plus

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

#next_plusObject

Computes the next adjacent floating point value. Accepts either a Value or a byte String. Returns a Value. TODO: use Flt



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/float-formats/classes.rb', line 200

def next_plus
  s,f,e = self.class.canonicalized(@sign,@significand,@exponent,true)
  return minus.next_minus.minus if s<0 && e!=:zero
  s = -s if e==:zero && s<0

  if e!=:nan && e!=:infinity
    if f==0
      if form_class.gradual_underflow?
        e = form_class.radix_min_exp(:integral_significand)
        f = 1
      else
        e = form_class.radix_min_exp(:integral_significand)
        f = form_class.minimum_normalized_integral_significand
      end
    else
      f += 1
    end
    if f>=form_class.radix_power(form_class.significand_digits)
      f /= form_class.radix
      if e==:denormal
        e = form_class.radix_min_exp(:integral_significand)
      else
        e += 1
      end
      if e>form_class.radix_max_exp(:integral_significand)
        e = :infinity
        f = 0
      end
    end
    form_class.new s, f, e
  end
end