Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/n8brooks/bijective_base
Tools for converting to and from bijective base numbers.
https://github.com/n8brooks/bijective_base
bijective-base-26 columns numeration typescript
Last synced: 7 days ago
JSON representation
Tools for converting to and from bijective base numbers.
- Host: GitHub
- URL: https://github.com/n8brooks/bijective_base
- Owner: N8Brooks
- License: mit
- Created: 2022-07-08T18:33:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-11T00:18:32.000Z (over 2 years ago)
- Last Synced: 2024-12-09T18:46:35.210Z (17 days ago)
- Topics: bijective-base-26, columns, numeration, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/bijective_base
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bijective_base
[![docs](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/bijective_base/mod.ts)
[![codecov](https://codecov.io/gh/N8Brooks/bijective_base/branch/main/graph/badge.svg?token=ZU38QLNOCG)](https://codecov.io/gh/N8Brooks/bijective_base)
[![build](https://github.com/N8Brooks/bijective_base/actions/workflows/ci.yaml/badge.svg)](https://github.com/N8Brooks/bijective_base/actions/workflows/ci.yaml)Tools for converting to and from
[bijective numeration](https://en.wikipedia.org/wiki/Bijective_numeration).## toBijectiveBase26
Converts non-negative integers to bijective base 26.
```ts
import { toBijectiveBase26 } from "https://deno.land/x/bijective_base/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";assertEquals(toBijectiveBase26(1), "a");
assertEquals(toBijectiveBase26(2), "b");
assertEquals(toBijectiveBase26(3), "c");assertEquals(toBijectiveBase26(26), "z");
assertEquals(toBijectiveBase26(27), "aa");
assertEquals(toBijectiveBase26(28), "ab");assertEquals(toBijectiveBase26(52), "az");
assertEquals(toBijectiveBase26(53), "ba");assertEquals(toBijectiveBase26(702), "zz");
assertEquals(toBijectiveBase26(703), "aaa");
```## fromBijectiveBase26
Converts bijective base 26 number to integers.
```ts
import { fromBijectiveBase26 } from "https://deno.land/x/bijective_base/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";assertEquals(fromBijectiveBase26("A"), 1);
assertEquals(fromBijectiveBase26("B"), 2);
assertEquals(fromBijectiveBase26("C"), 3);assertEquals(fromBijectiveBase26("Z"), 26);
assertEquals(fromBijectiveBase26("AA"), 27);
assertEquals(fromBijectiveBase26("AB"), 28);assertEquals(fromBijectiveBase26("AZ"), 52);
assertEquals(fromBijectiveBase26("BA"), 53);assertEquals(fromBijectiveBase26("ZZ"), 702);
assertEquals(fromBijectiveBase26("AAA"), 703);
```