98 lines
3.2 KiB
Markdown
Raw Normal View History

2023-06-22 18:50:03 +02:00
[![Arduino CI](https://github.com/RobTillaart/integer24/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/integer24/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/integer24/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/integer24/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/integer24/actions/workflows/jsoncheck.yml)
2023-11-07 14:29:20 +01:00
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/integer24.svg)](https://github.com/RobTillaart/integer24/issues)
2023-06-22 18:50:03 +02:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/integer24/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/integer24.svg?maxAge=3600)](https://github.com/RobTillaart/integer24/releases)
2023-11-07 14:29:20 +01:00
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/integer24.svg)](https://registry.platformio.org/libraries/robtillaart/integer24)
2023-06-22 18:50:03 +02:00
# integer24
Arduino library for the integer24 data types uint24_t and int24_t.
## Description
The integer24 is an **experimental** library to implement support
for the following two 24 bit data types:
- **int24_t**
- **uint24_t**
Version 0.1.0 implements a **typedef** for both types.
Note: AVR does support __uint24 and __int24 which uses only 3 bytes.
2023-11-07 14:29:20 +01:00
This allows an UNO to have ~30% more elements (in theory) in an array
with the same memory usage as an uint32_t array.
This library is only (limited) tested with AVR - UNO.
2023-06-27 18:28:02 +02:00
So use with care.
2023-06-22 18:50:03 +02:00
#### Range
| platform | type | minimum | maximum | notes |
|:----------:|:----------:|:-----------:|:----------:|:-----------|
| AVR | uint24_t | 0 | 16777215 | __uint24 |
| AVR | int24_t | -8388608 | 8388607 | __int24 |
| other | uint24_t | 0 | 4294967296 | uint32_t for now |
| other | int24_t | -2147483648 | 2147483648 | int32_t for now |
Note the range for other platforms may change in the future to
those matching AVR.
If other platforms are known to implement (3byte) int24 data types
2023-06-27 18:28:02 +02:00
please let me know so I can add these.
2023-06-22 18:50:03 +02:00
#### Known limitations
- The AVR uint24_t and int24_t cannot be printed without casting.
2023-06-27 18:28:02 +02:00
- see integer24_explore_printing.ino
2023-06-22 18:50:03 +02:00
- Arduino-CI does not implement __int24 __uint24 so no tests can be done.
2023-11-07 14:29:20 +01:00
## Interface
```cpp
#include "integer24.h"
```
2023-06-22 18:50:03 +02:00
## Future
#### Must
2023-11-07 14:29:20 +01:00
- update documentation
2023-06-22 18:50:03 +02:00
- get hands on experience, especially AVR
2023-06-27 18:28:02 +02:00
- document what is learned.
2023-06-22 18:50:03 +02:00
#### Should
2023-06-27 18:28:02 +02:00
- implement **char \* convert24(int24_t)** and **char \* convert24(uint24_t)**
- length = 8 + \0 = 9
- fprintf(buf, "%d", (uint32_t)val); ?
- char * itoa ( int value, char * str, int base );
- see integer24_explore_printing.ino
2023-06-22 18:50:03 +02:00
#### Could
2023-06-27 18:28:02 +02:00
- implement a class for both types
2023-06-22 18:50:03 +02:00
- implement **printTo()**
2023-06-27 18:28:02 +02:00
- basic math, comparison, negation, ...
2023-06-22 18:50:03 +02:00
#### Won't
2023-11-07 14:29:20 +01:00
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,