Skip to content

Commit

Permalink
Finalise first version
Browse files Browse the repository at this point in the history
Initial PR (#2)

* Add conversions to and from decimals (#1)

* Add convertions to and from decimals

* Remove codecov

* Update circleci config.yml

* Add github action for goveralls

* Finish initial version

* Update README.md

Rename to numerals

Refactor

Update README.md

Update README.md change equations

Update README.md change equations

Update equations on README.md

Update README.md add TOC

Update README.md

Update README.md
  • Loading branch information
slysterous committed Apr 13, 2021
1 parent dd0e8ea commit bb04882
Show file tree
Hide file tree
Showing 10 changed files with 633 additions and 298 deletions.
15 changes: 5 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2.1
orbs:
codecov: codecov/codecov@1.1.1

jobs:
build:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/slysterous/custom-number
- image: circleci/golang:1.15
working_directory: /go/src/github.com/slysterous/numeral
steps:
- checkout
- run: go get golang.org/x/lint/golint
- run: make fmt
- run: make ci
- run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- codecov/upload:
file: './coverage.txt'
token: 9b1131be-d1fa-4091-bf1d-2761a84e3f3b

- run: go test -v -cover -race -coverprofile=coverage.out
- run: go get github.com/mattn/goveralls
- run: GO111MODULE=off $GOPATH/bin/goveralls -coverprofile=coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
18 changes: 0 additions & 18 deletions .codecov.yml

This file was deleted.

79 changes: 39 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# custom-number [![PkgGoDev](https://pkg.go.dev/badge/github.com/slysterous/custom-number)](https://pkg.go.dev/github.com/slysterous/custom-number)
# numeral [![PkgGoDev](https://pkg.go.dev/badge/github.com/slysterous/numeral)](https://pkg.go.dev/github.com/slysterous/numeral)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
[![CircleCI](https://circleci.com/gh/slysterous/custom-number.svg?style=shield)](https://circleci.com/gh/slysterous/custom-numbers)
[![codecov](https://codecov.io/gh/slysterous/custom-number/branch/main/graph/badge.svg?token=057BbZbRE4)](https://codecov.io/gh/slysterous/custom-number)
[![Go Report Card](https://goreportcard.com/badge/github.com/slysterous/custom-number)](https://goreportcard.com/report/github.com/slysterous/custom-number)
[![CircleCI](https://circleci.com/gh/slysterous/numeral.svg?style=shield)](https://circleci.com/gh/slysterous/numerals)
[![Coverage Status](https://coveralls.io/repos/github/slysterous/numeral/badge.svg?branch=main)](https://coveralls.io/github/slysterous/numeral?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/slysterous/numeral)](https://goreportcard.com/report/github.com/slysterous/numeral)

numerals based on custom positional (numeral) systems.

Custom numbers based on custom numeral systems.
## Table of Contents ##
## 📝 About ##

## About ##

### Why
There are times, where we need to iterate over an X amount of possible combinations of values over a specific number or a specific string etc.
### 🧠 Why
There are times, where we need to iterate over an X amount of possible combinations of values over a
specific number or a specific string etc or be able to perform basic operations on these type of numerals
<strong> (iterators, rainbow tables, numeral system converters) </strong>

For example, if you have an identifier that can contain values that are either 0-9 and a-z and A-Z and you would want to know each possible
Expand All @@ -35,13 +34,13 @@ Now, if you wanted to find all the possible combinations of numbers, for 4 digit
```
These are <strong>916.132.832</strong> different possible combinations.

### How
A <strong>numeral</strong> is a symbol or group of symbols that <strong>represents a number</strong>. Numerals are not the
### ♟️ How
A <strong>numeral</strong> is a symbol or group of symbols that <strong>represents a number</strong>. numeral are not the
same as numbers just as words are not the same with the things they refer to. The symbols <strong>"11", "1011" and "B"</strong>
are different numerals, all representing the same number.
are different numeral, all representing the same number.

A <strong>numeral</strong> system (or system of numeration) is a <strong>framework</strong> where a set of numbers are
represented by numerals in a consistent manner. It can be seen as the context that allows the numeral <strong>"11"</strong> to be interpreted
represented by numeral in a consistent manner. It can be seen as the context that allows the numeral <strong>"11"</strong> to be interpreted
as the binary numeral for <strong>three</strong>, the decimal numeral for <strong>eleven</strong>, or other numbers in different bases.

Ideally, such a system will:
Expand All @@ -67,68 +66,68 @@ The base is an integer that is greater than 1 (or less than negative 1), since a

In base-10 (decimal) positional notation, there are 10 decimal digits and the number

![decimal equation](https://latex.codecogs.com/svg.latex?2056=(2%20*%2010^3%20)+(5%20*%2010^2)%20+(0%20*%2010%20^1)+(6*10^0))

![decimal equation](https://latex.codecogs.com/png.latex?\bg_white&space;2056=(2%20*%2010^3%20)+(5%20*%2010^2)%20+(0%20*%2010%20^1)+(6*10^0))
In base-16 (hexadecimal), there are 16 hexadecimal digits (0–9 and A–F) and the number

![hex equation](https://latex.codecogs.com/svg.latex?171B=(1*16^3)+(7*16^2)+(1*16^1)+(B*16^0)) (where B represents the number eleven as a single symbol)
![hex equation](https://latex.codecogs.com/png.latex?\bg_white&space;171B=(1*16^3)+(7*16^2)+(1*16^1)+(B*16^0)) (where B represents the number eleven as a single symbol)

In general, in base-b, there are b digits and the number

![base equation](https://latex.codecogs.com/svg.latex?a_3a_2a_1a_0=(a_3%20*%20b^3)+(a_2*b^2)+(a_1*b^1)+(a_0*b^0))
(Note that ![base digits](https://latex.codecogs.com/svg.latex?a_3a_2a_1a_0) represents a sequence of digits, not multiplication)
![base equation](https://latex.codecogs.com/png.latex?\bg_white&space;a_3a_2a_1a_0=(a_3%20*%20b^3)+(a_2*b^2)+(a_1*b^1)+(a_0*b^0))
(Note that ![base digits](https://latex.codecogs.com/png.latex?\bg_white&space;a_3a_2a_1a_0) represents a sequence of digits, not multiplication)

### What
This library, <strong>customnumber</strong> provides the ability to create custom positional numeral systems in an efficient and performant way.
You can create custom numbers based on custom numeral systems and use them at will.
### What
This library, <strong>numeral</strong> provides the ability to create custom positional numeral systems in an efficient and performant way.
You can create numerals based on custom numeral systems and use them at will.

All you need is the possible values of a digit (e.g. 0123456789ABCDEF) and an initial number (e.g. 14FF)

To implement our HOW we utilize 2 standard library packages:
* [container/ring](https://golang.org/pkg/container/ring/) (circular list)
* [container/list](https://golang.org/pkg/container/list/) (doubly linked list)

Each digit represented as a circular list that contains the all the possible numerals.
Each digit represented as a circular list that contains the all the possible numeral.

Each number is represented as a doubly linked list of circular lists.

When a digit rotates back to it's first digit as a result of an addition, then an arithmetic holding is generated
and because of the doubly linked list it rotates the next, in weight digit, once. The opposite thing happens when a subtraction is happening.

## Getting Started ##
All you need is at least <strong>GO 1.13</strong>
## Usage ##
## 🎬 Getting Started ##
All you need is at least <strong>GO 1.15</strong>
## 🤓 Usage ##
Get the package
```bash
go get github.com/slysterous/custom-number
go get github.com/slysterous/numeral
```
Then all you need to do is create a custom number
Then all you need to do is create a numeral.
For full reference on usage and available methods visit [pkg.go.dev](https://pkg.go.dev/badge/github.com/slysterous/numeral)
```gotemplate
// create a slice of runes.
digitValues := []rune{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
number := customnumber.NewNumber(digitValues, "128z")
number := numeral.NewNumeral(digitValues, "128z")
// will make the number 1290.
number.Increment()
number2, err := numeral.NewFromDecimal(digitValues, 150)
// will make the number 128y.
number.Decrement()
//will give you the string representation of the number.
strnumber:=number.String()
strnumber:=number2.String()
//will give you the decimal integer representation of the number.
intnumber:=number.Decimal()
```
### Make Utilities
### ⛩️ Make Utilities
```bash
ci run ci
fmt gofmt all files excluding vendor
lint perform linting
test run tests
```
## Contributing ##
Refer to [Contributing](https://github.com/slysterous/custom-number/blob/main/CONTRIBUTING.md).
## Report bugs using Github's [issues](https://github.com/slysterous/custom-number/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/slysterous/custom-number/issues);
## License ##
## ℹ️ Contributing ##
Refer to [Contributing](https://github.com/slysterous/numeral/blob/main/CONTRIBUTING.md).
## 🐛 Report bugs using Github's [issues](https://github.com/slysterous/numeral/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/slysterous/numeral/issues);
## ⚖️ License ##
This library is distributed under the MIT license found in the [LICENSE](./LICENSE)
file.
136 changes: 0 additions & 136 deletions customnumber.go

This file was deleted.

Loading

0 comments on commit bb04882

Please sign in to comment.