Class: Integer
Class Method Summary
collapse
Instance Method Summary
collapse
append_features, #nio_round, #nio_write
Class Method Details
.nio_read_neutral(neutral) ⇒ Object
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
|
# File 'lib/nio/fmt.rb', line 1707
def self.nio_read_neutral(neutral)
x = nil
if neutral.special?
raise Nio::InvalidFormat,"Invalid integer numeral"
elsif neutral.rep_pos<neutral.digits.length
return Rational.nio_read_neutral(neutral).to_i
else
digits = neutral.digits
if neutral.dec_pos <= 0
digits = '0'
elsif neutral.dec_pos <= digits.length
digits = digits[0...neutral.dec_pos]
else
digits = digits + '0'*(neutral.dec_pos-digits.length)
end
x = digits.to_i(neutral.base)
x = -x if neutral.sign=='-'
end
return x
end
|
Instance Method Details
#nio_write_neutral(fmt) ⇒ Object
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
|
# File 'lib/nio/fmt.rb', line 1736
def nio_write_neutral(fmt)
neutral = Nio::NeutralNum.new
x = self
sign = x<0 ? '-' : '+'
txt = x.abs.to_s(fmt.get_base)
dec_pos = rep_pos = txt.length
neutral.set sign, txt, dec_pos, nil, fmt.get_base_digits, false ,fmt.get_round
return neutral
end
|
#nio_xr ⇒ Object
83
84
85
|
# File 'lib/nio/rtnlzr.rb', line 83
def nio_xr
return Rational(self,1)
end
|