p

pips

v4e1b45dlibrary

Visualise numbers bitwise as strings

0 stars0 forksUnknownupdated 6 months ago
Open repo

pips A library to convert a bitmap into a series of characters.

TL;DR

Given a number, print a unique character for each bit that is '1'.

Example from the shell command

$ ./pips-cli 42                                                                                                                                                                            
.B.D. F.... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ....

API

byte_to_rune :: proc(bit: byte) -> rune

Gives a rune for a particular bit number less than 64

lower powers are alphanumeric

0 -> 'A'
1 -> 'B'
...
25 -> 'Z'
26 -> 'a'
...
51 -> 'z'
52 -> '0'
61 -> '9'

higher powers are not alphanumeric

62 -> '$'
63 -> '%'

toPips :: proc(bits: u64, max: byte = 63) -> string

Given a number less than 2^64 output a string of unique characters one per bit in groups of five. The return value is allocated by context.allocator.

1 -> "A.... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...."
2 -> ".B... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...."
4 -> "..C.. ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...."
7 -> "ABC.. ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...."
2^62 (is 4611686018427387904) -> "..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..$."`

`2^63 (is 9223372036854775808) -> "..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...%"``

all the bts set:

18446744073709551615 -> "ABCDE FGHIJ KLMNO PQRST UVWXY Zabcd efghi jklmn opqrs tuvwx yz012 34567 89$%"

pips-cli

A command which takes a bitwise number as it argument, and prints the pips

$ ./pips-cli 42                                                                                                                                                                            
.B.D. F.... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ....
Package Info
Version
v4e1b45d
License
Unknown
Author
@birchb1024
Type
library
Forks
0
Created
6 months ago
Updated
6 months ago
Health
maintained
has releases
has readme
has license
Activity
last 56 weeks