Sha256: b702e0cc479edc92251d8726f805e60595a28baafad468ca287cc4f0a7ce7f88
Contents?: true
Size: 742 Bytes
Versions: 1
Compression:
Stored size: 742 Bytes
Contents
= Radix Rational Radix also provides a Rational class. Like the Integer and Float classes Radix::Rational delegates to an underlying instance of Ruby standard Rational class. require 'radix' b = ["100","10"].br(2) b.assert = [2,1].br(10) When convert to Array or String Radix::Rational uses `/` to separate the numerator from the denominator. b.to_a #=> [1,0,0,'/',1,0] b.to_s #=> "100/10" To use a custom character set, use an array of characters as the base rather than an integer. For example we can convert a base 10 number to another base 10 number but useing a different encoding. base = %w[Q W E R T Y U I O U] ["10","1"].br(10).to_a(base) #=> ["W", "Q", '/', 'W'] ["10","1"].br(10).to_s(base) #=> "WQ/W"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radix-2.0.0 | doc/04_rational.rdoc |