Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Any formats can mean positional/unary numeral systems :)

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/integer
test
.gitignore
.travis.yml
Gemfile
History.rdoc
LICENSE
Manifest.txt
README.rdoc
Rakefile
integer-base.gemspec

README.rdoc

integer-base

Description

Original formats come into positional/unary numeral systems.

Feautures

  • Positional numeral systems with free characters, that your selection

  • Unary numeral system with a free character, that your selection

  • You can build upper 36 basenumbers so easily

  • And get own formats so easily too :)

    e.g.

    • 0 1 -> 0 a

    • 0 1 2 3 4 5 6 7 8 9 -> a b c d e f g h i j

Usage

  • Setup

    require 'integer/base'
  • Basic

    Integer::Base.parse '10', %w[0 1]   #=> 2
  • Extend Ruby's Interface

    require 'integer/base/ext'
  • to_i

    'a'.to_i   ['0', *'A'..'I']        #=> 1
    'a0'.to_i  ['0', *'A'..'I']        #=> 10
    'aib'.to_i ['0', *'A'..'I']        #=> 192
  • to_s

    192.to_s   ['0', *'A'..'I']        #=> 'aib'
  • Already defined useful chars

    '10'.to_i Integer::Base::STANDARD_CHARS[36].last         #=> :Z
    '10'.to_i Integer::Base::STANDARD_CHARS[:BINARY].last    #=> :"1"
  • Get own formats

    'a'.to_i  %w[0 a]                  #=> 1
    'a0'.to_i %w[0 a]                  #=> 2
  • Upper 36 basenumbers

    '1!'.to_i([*Integer::Base::STANDARD_CHARS[36], '!']) #=> 73

Requirements

  • Ruby 1.9.2 or later

Installation

gem install integer-base

Links

code

github.com/kachick/integer-base

issues

github.com/kachick/integer-base/issues

CI

travis-ci.org/#!/kachick/integer-base

gem

rubygems.org/gems/integer-base

gem+

metagem.info/gems/integer-base

License

The MIT X License

Copyright © 2011 Kenichi Kamiya

See the file LICENSE for further details.

Something went wrong with that request. Please try again.