Skip to content
Any formats can mean positional/unary numeral systems :)
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib/integer
test
.gitignore
.travis.yml
.yardopts
Gemfile
LICENSE
README.md
Rakefile
integer-base.gemspec

README.md

integer-base

Build Status Gem Version

Description

Any formats can mean positional/unary numeral systems :)
So base number conversion under your choice.

Features

  • You can easily build base numbers.
  • An example, upper the "36".

Usage

Introduction

require 'integer/base'

Integer::Base.parse '10', %w[0 1 2 3 4 5 6 7 8 9]   #=> 10


using Integer::Base

'10'.to_i %w[0 1]                                   #=> 2
10.to_s   %w[0 1]                                   #=> "2"

Upper 36 base number

'10'.to_i 36                                        #=> 36
'10'.to_i [*'0'..'9', *'A'..'Z']                    #=> 36
'10'.to_i 37                                        #=> ArgumentError
'10'.to_i [*'0'..'9', *'A'..'Z', '?']               #=> 37
'1?'.to_i [*'0'..'9', *'A'..'Z', '?']               #=> 73 (37 * 1 + 36 * 1)

Let's begin, your strange base number.

':)'.to_i %w[) :]                                   #=> 2

Requirements

Install

$ gem install integer-base

Link

License

The MIT X11 License
Copyright (c) 2011 Kenichi Kamiya
See MIT-LICENSE for further details.

You can’t perform that action at this time.