Hangar.La tienda de software del Amiga

bytes 0.0.4

Byte <-> string conversion library

Short:        Byte <-> string conversion library
Author:       TJ Holowaychuk, Joseph Werle and others
Uploader:     Carsten Larsen (carsten larsen mail com)
Type:         dev/lib
Version:      0.0.4
Architecture: generic; m68k-amigaos
URL:          https://github.com/clibs/bytes.git

About

    Convert byte length strings such as "5kb" to a long long and vice versa.

Installation

    Copy byte.h and byte.c to your source code tree.

Usage

    void test_string_to_bytes(void) {
        assert(100 == string_to_bytes("100"));
        assert(100 == string_to_bytes("100b"));
        assert(100 == string_to_bytes("100 bytes"));
        assert(1024 == string_to_bytes("1kb"));
        assert(1024 * 1024 == string_to_bytes("1mb"));
        assert(1024 * 1024 * 1024 == string_to_bytes("1gb"));
        assert(2 * 1024 == string_to_bytes("2kb"));
        assert(5 * 1024 * 1024 == string_to_bytes("5mb"));
    }

    void test_bytes_to_string(void) {
        equal("100b", bytes_to_string(100));
        equal("1kb", bytes_to_string(1024));
        equal("1mb", bytes_to_string(1024 * 1024));
        equal("5mb", bytes_to_string(1024 * 1024 * 5));
        equal("1gb", bytes_to_string(1024 * 1024 * 1024));
        equal("5gb", bytes_to_string((long long) 1024 * 1024 * 1024 * 5));
    }

API

    long long
    string_to_bytes(const char *str);

    char *
    bytes_to_string(long long bytes);

License

    MIT

Gratis

Web del proyecto ↗

Descargar 27 KB

Desde el Amiga: abre Hangar y busca bytes.

AutorTJ Holowaychuk, Joseph Werle and others
Categoríadev/lib
Tamaño27 KB
Fecha2025-12-05
Parageneric; m68k-amigaos
Webhttps://github.com/clibs/bytes.git
OrigenAminet