Module: Nio::Rtnlzr::Mth

Defined in:
lib/nio/rtnlzr.rb

Overview

Auxiliary floating-point functions

Class Method Summary collapse

Class Method Details

.abs(x) ⇒ Object



399
400
401
# File 'lib/nio/rtnlzr.rb', line 399

def self.abs(x)
  x.abs
end

.ceil(x) ⇒ Object



403
404
405
406
# File 'lib/nio/rtnlzr.rb', line 403

def self.ceil(x)
  # Note that ceil returns an Integer for Float and Flt::Num, but not for BigDecimal
  x.ceil.to_i
end

.fp(x) ⇒ Object

:nodoc:



384
385
386
387
# File 'lib/nio/rtnlzr.rb', line 384

def self.fp(x)
  # y =x.modulo(1); return x<0 ? -y : y;
  x-ip(x)
end

.ip(x) ⇒ Object



389
390
391
392
# File 'lib/nio/rtnlzr.rb', line 389

def self.ip(x)
  # Note that ceil, floor return an Integer for Float and Flt::Num, but not for BigDecimal
  (x<0 ? x.ceil : x.floor).to_i
end

.rnd(x) ⇒ Object



394
395
396
397
# File 'lib/nio/rtnlzr.rb', line 394

def self.rnd(x)
  # Note that round returns an Integer for Float and Flt::Num, but not for BigDecimal
  x.round.to_i
end