Module: Nio

Defined in:
lib/nio/version.rb,
lib/nio/fmt.rb,
lib/nio/sugar.rb,
lib/nio/tools.rb,
lib/nio/repdec.rb,
lib/nio/rtnlzr.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Formattable, StateEquivalent, VERSION Classes: DigitsDef, Fmt, NeutralNum, RepDec, RepDecError, Rtnlzr

Class Method Summary collapse

Class Method Details

.convert(x, type, mode = :approx) ⇒ Object

This is not a module function: this provides a shorthand access to Nio::Fmt.convert



26
27
28
# File 'lib/nio/sugar.rb', line 26

def Nio.convert(x, type, mode=:approx)
  Nio::Fmt.convert x, type, mode
end

.Fmt(options = nil) ⇒ Object



1283
1284
1285
# File 'lib/nio/fmt.rb', line 1283

def Fmt(options=nil)
  Fmt.default(options)
end

.gcd(a, b) ⇒ Object



500
501
502
503
504
505
# File 'lib/nio/repdec.rb', line 500

def gcd(a,b)
  while b!=0 do
    a,b = b, a.modulo(b)
  end
  return a.abs;
end

.nio_convert(x, type, mode = :approx) ⇒ Object

This module function can be used after import Nio



33
34
35
# File 'lib/nio/sugar.rb', line 33

def nio_convert(x, type, mode=:approx)
  Nio::Fmt.convert x, type, mode
end

.nio_float_to_bigdecimal(x, prec) ⇒ Object

:nodoc:



1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
# File 'lib/nio/fmt.rb', line 1287

def nio_float_to_bigdecimal(x,prec) # :nodoc:
  if prec.nil?
    x = Fmt.convert(x,BigDecimal,:approx)
  elsif prec==:exact
    x = Fmt.convert(x,BigDecimal,:exact)
  else
    x = BigDecimal(x.nio_write(Nio::Fmt.new.prec(prec,:sig)))
  end
  x
end