Liking cljdoc? Tell your friends :D

# base

A tiny Clojure library for converting decimals to different base representations.

## Quick Start

``````clj -Sdeps '{:deps {com.evanjbowling/base {:mvn/version "0.1.0"}}}' \
-e "(require '[com.evanjbowling.base :as b])(b/to-base 1234567.8901M 13)"
``````

Output:

``````"342C19.B7571B8C9B₁₃"
``````

## Install

Leiningen/Boot:

``````[com.evanjbowling/base "0.1.0"]
``````

Clojure CLI/deps.edn:

``````com.evanjbowling/base {:mvn/version "0.1.0"}
``````

## Use

Review the Docs.

``````(require '[com.evanjbowling.base :as b])
``````

There are two main functions:

• `to-base` - returns a string representation
• `to-base-seq` - returns a sequence of numeric values (For every value v, 0 <= v < base) with two parts: integer sequence and fractional sequence.

The sequence version is meant to be useful for exploring the whole sequence (the fractional sequence may be infinite) or for encoding the values in another format (e.g. HTML).

### String Representations

The `to-base` function maps every digit value in the sequence to the relevant character for the base.

Convert simple decimals:

``````(b/to-base 16.25M 2)  ; "10000.01₂"
(b/to-base 16.25M 16) ; "10.4₁₆"
``````

Convert larger decimals:

``````(b/to-base 134983783748.98374983798374M 64) ; "B9tqRVE.-9cHhZXg1G₆₄"
(b/to-base 8561238652.018972M 37)           ; "3CH1F0G.0PZaLKFZT7₃₇"
``````

Custom digit mapping:

``````(b/to-base 16.25M 2 {:b/digit-mapping "XO"}) ; "OXXXX.XO₂"
``````

## TODO

• review convenience fns, add common name aliases
• proper docs
• review rational support
• repeating rationals not currently supported
• document and expand options map with formatting options (add sequence format)
• repeating fractional sequence detection
• branch with spec usage

## Dedicate

This library is dedicated to the second sentence of the second paragraph of sections 5.1 and 5.2 on page 11 of rfc6234.