Convert digit strings between arbitrary bases.

Related tags

Utilities basexx
Overview

Basexx - Convert between digit strings and various number bases

Go Reference Go Report Card Tests Coverage Status

This is basexx, a package for converting numbers to digit strings in various bases and vice versa.

Usage

To get the Base30 encoding of the number 412:

result, err := basexx.Digits(412, basexx.Base30)

To decode the base30 digit string "fr":

result, err := basexx.Value("fr", basexx.Base30)

To convert a digit string x in base from to a new digit string in base to:

var (
  src     = basexx.NewBuffer(x, from)
  destbuf = make([]byte, basexx.Length(from, to, len(x)))
  dest    = basexx.NewBuffer(destbuf, to)
)
_, err := Convert(dest, src)
if err != nil { ... }
result := dest.Written()

To define your own new number base:

// ReverseBase10 uses digits '9' through '0' just to mess with you.
type ReverseBase10 struct{}

func (ReverseBase10) N() int64 { return 10 }

func (ReverseBase10) Encode(val int64) (byte, error) {
  if val < 0 || val > 9 {
    return 0, errors.New("digit value out of range")
  }
  return byte('9' - val), nil
}

func (ReverseBase10) Decode(digit byte) (int64, error) {
  if digit < '0’ || digit > '9' {
    return 0, errors.New("invalid encoded digit")
  }
  return int64(9 - (digit - '0’))
}
randstr is a module that contains functions for generating random strings.

randstr is a module that contains functions for generating random strings. The functions in this module uses the crypto/rand package. Installa

Henrik Christensen 3 Nov 13, 2021
Simple go package which converts roman strings to integer

romanparse Simple go package which converts roman strings

Caio Ribeiro Pereira 2 Oct 6, 2021
Simple library to handle ANSI functions and parsing of color formatting strings

Emerald A basic color library for use in my Go projects, built on top of mgutz/ansi. Package ansi is a small, fast library to create ANSI colored stri

Josh Willox 0 Nov 15, 2021
checkspaces is a checker for spaces between // and directives.

checkspaces checks if there is a space between // and directives.

masibw 2 Dec 10, 2021
CSPFinder is a tool to compare ROI of selling Cash Secure Put options between different tickers for different expiry dates.

CSPFinder is a tool to compare ROI of selling Cash Secure Put options between different tickers for different expiry dates. It is intended to help open new cash secured put positions.

Sreenidhi Sreesha 26 Dec 21, 2021
Slice conversion between primitive types

sliceconv Sliceconv implements conversions to and from string representations of primitive types on entire slices. The package supports types int, flo

Henry Sarabia 7 May 1, 2021
Convert Arabic numeric amounts to Chinese character

将阿拉伯数字金额转换为汉字的形式 Convert Arabic numeric amounts to Chinese character form. 安装使用 Golang 版本大于等于1.16 go get -u github.com/aliliin/rmb-character import (

高永立 4 Sep 9, 2021
krconv -- Convert kana-character to roman-alphabet

krconv -- Convert kana-character to roman-alphabet Convert kana-characters to roman-alphabets (by hepburn romanization) This package is required Go 1.

Spiegel 3 Oct 13, 2021
Package strnaming is used to Convert string to camelCase, snake_case, kebab-case.

strnaming Package strnaming is used to Convert string to camelCase, snake_case, kebab-case. Contents strnaming Contents API Examples Install Quick sta

null 2 Oct 24, 2021
Convert Gitignore to Glob patterns in Go

globify-gitignore Convert Gitignore to Glob patterns A Go

Amin Yahyaabadi 5 Nov 8, 2021
go-to64 analyzes Golang main package to convert int/uint to int64/uint64.

go-to64 About go-to64 analyzes Golang main package to convert int/uint to int64/uint64. This is an experiment tool, so be very careful. In a 32-bit en

Tomohiro Takezawa 1 Oct 31, 2021
A Go utility to convert Go example tests into jupyter notebooks.

go2colab Scientists (my main project's users) love jupyter notebook tutorials pkg.dev.go's runnable playground doesn't support file IO but I love exam

Tim 2 Nov 8, 2021
Convert dates from or to 31 calendars in Go. Implements the functions discussed in Reingold/Dershowitz 2018.

libcalcal - Calendrical calculations in Go About libcalcal implements in Go the functions described and presented in: Reingold, Edward M., and Nachum

null 1 Dec 30, 2021
A tools web api bases golang

1. tools-api 一个基于golang的开源web服务,专注于提供各类API以便在日常开发中提高生产效率 2. 部署 下载二进制程序后直接运行即可 ./go-tools-api 3. 二次开发 3.1. 环境依赖 Go版本 go version go1.15.2 linux/amd64 环境

chancel 0 Dec 6, 2021
PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

Velmie 1 Nov 2, 2021
A program to create assembly 8086 strings to print without using any printing/strings related function but only mov-xchg-int and loops

Assembly String builder tool A program to create assembly 8086 strings to print without using any printing/strings related function but only mov-xchg-

Reg 2 Nov 11, 2021
Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command under your project: go get

Afeyer 99 Dec 16, 2021
Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct-tool Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command und

Afeyer 1 Dec 16, 2021
repin is a tool to replace strings between keyword pair.

repin repin is a tool to replace strings between keyword pair. tl;dr repin is a tool that makes it easy to write operations that can be written in GNU

Ken’ichiro Oyama 1 Jan 7, 2022
Read data from rss, convert in pdf and send to kindle. Amazon automatically convert them in azw3.

Kindle-RSS-PDF-AZW3 The Kindle RSS PDF AZW3 is a personal project. The Kindle RSS PDF AZW3 is a personal project. I received a Kindle for Christmas, a

Elia 0 Jan 10, 2022
:handbag: Cache arbitrary data with an expiration time.

cache Cache arbitrary data with an expiration time. Features 0 dependencies About 100 lines of code 100% test coverage Usage // New cache c := cache.N

Eduard Urbach 99 Jan 13, 2022
Arbitrary-precision fixed-point decimal numbers in go

decimal Arbitrary-precision fixed-point decimal numbers in go. Note: Decimal library can "only" represent numbers with a maximum of 2^31 digits after

Spring Engineering 3.7k Jan 19, 2022
smartcrop finds good image crops for arbitrary crop sizes

smartcrop smartcrop finds good image crops for arbitrary sizes. It is a pure Go implementation, based on Jonas Wagner's smartcrop.js Image: https://ww

Christian Muehlhaeuser 1.6k Jan 14, 2022
Arbitrary transformations of JSON in Golang

kazaam Description Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang. This functionality provides

Qntfy 216 Jan 13, 2022
An arbitrary-precision decimal floating-point arithmetic package for Go

decimal Package decimal implements arbitrary-precision decimal floating-point arithmetic for Go. Rationale How computers represent numbers internally

Denis Bernard 23 Nov 16, 2021
An arbitrary-precision decimal floating-point arithmetic package for Go

decimal Package decimal implements arbitrary-precision decimal floating-point arithmetic for Go. Rationale How computers represent numbers internally

Denis Bernard 23 Nov 16, 2021
Arbitrary-precision fixed-point decimal numbers in go

decimal Arbitrary-precision fixed-point decimal numbers in go. Note: Decimal library can "only" represent numbers with a maximum of 2^31 digits after

Spring Engineering 3.7k Jan 16, 2022
Arbitrary-precision decimals for Go

apd apd is an arbitrary-precision decimal package for Go. apd implements much of the decimal specification from the General Decimal Arithmetic descrip

CockroachDB 379 Jan 12, 2022
Arbitrary expression evaluation for golang

govaluate Provides support for evaluating arbitrary C-like artithmetic/string expressions. Why can't you just write these expressions in code? Sometim

George Lester 2.2k Jan 16, 2022