Class: Integer
Class Method Summary
collapse
Instance Method Summary
collapse
append_features, #nio_round, #nio_write
Class Method Details
.nio_read_neutral(neutral) ⇒ Object
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
|
# File 'lib/nio/fmt.rb', line 1509
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
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
|
# File 'lib/nio/fmt.rb', line 1538
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
87
88
89
|
# File 'lib/nio/rtnlzr.rb', line 87
def nio_xr
return Rational(self,1)
end
|