mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.2.5 IEEE754tools
This commit is contained in:
parent
3c8e2ae473
commit
d36c3b366f
@ -1,4 +1,4 @@
|
||||
# Change Log I2CKeyPad8x8
|
||||
# Change Log IEEE754tools
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
@ -6,12 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.2.5] - 2023-11-06
|
||||
- update readme.md
|
||||
- fix CHANGELOG.md
|
||||
- renamed IEEE754_VERSION to IEEE754_LIB_VERSION
|
||||
- minor edits examples.
|
||||
|
||||
|
||||
## [0.2.4] - 2022-11-12
|
||||
- Add RP2040 support to build-CI.
|
||||
- Add CHANGELOG.md
|
||||
- minor edit unit test
|
||||
|
||||
|
||||
## [0.2.3] - 2021-12-20
|
||||
- update library.json, license, minor edits
|
||||
|
||||
|
@ -2,23 +2,21 @@
|
||||
//
|
||||
// FILE: IEEE754tools.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.4
|
||||
// VERSION: 0.2.5
|
||||
// PURPOSE: manipulate IEEE754 float numbers fast
|
||||
// URL: https://github.com/RobTillaart/IEEE754tools.git
|
||||
//
|
||||
// HISTORY: see changelog.md
|
||||
//
|
||||
// EXPERIMENTAL ==> USE WITH CARE
|
||||
// not tested extensively,
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define IEEE754_VERSION (F("0.2.4"))
|
||||
#define IEEE754_LIB_VERSION (F("0.2.5"))
|
||||
|
||||
|
||||
// (un)comment lines to configure functionality / size
|
||||
//#define IEEE754_ENABLE_MSB // +78 bytes
|
||||
// #define IEEE754_ENABLE_MSB // +78 bytes
|
||||
|
||||
|
||||
// IEEE754 float layout;
|
||||
@ -169,7 +167,7 @@ float doublePacked2Float(byte* bar, int byteOrder = LSBFIRST)
|
||||
}
|
||||
#endif
|
||||
|
||||
int e = dbl.p.e - 1023 + 127; // exponent adjust
|
||||
int e = dbl.p.e - 1023 + 127; // e xponent adjust
|
||||
// TODO check exponent overflow.
|
||||
if (e >=0 || e <= 255)
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
// FILE: FastNegate.ino
|
||||
// AUTHOR: Rob dot Tillaart at gmail dot com
|
||||
// PURPOSE: Fast negate for floating points
|
||||
//
|
||||
|
||||
#include "IEEE754tools.h"
|
||||
|
||||
volatile float zz = 100;
|
||||
volatile int x = 3;
|
||||
@ -14,7 +14,10 @@ uint32_t start, duration1, duration2;
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("IEEE754_LIB_VERSION: ");
|
||||
Serial.println(IEEE754_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
test_negfabs();
|
||||
|
@ -17,7 +17,11 @@ volatile bool b;
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("IEEE754_LIB_VERSION: ");
|
||||
Serial.println(IEEE754_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
test_FLOAT_EQ_1();
|
||||
test_FLOAT_EQ_2();
|
||||
|
@ -16,6 +16,11 @@ byte x[8];
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("IEEE754_LIB_VERSION: ");
|
||||
Serial.println(IEEE754_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
test1();
|
||||
test2();
|
||||
@ -79,7 +84,7 @@ void test4()
|
||||
float2DoublePacked(1.23456789e38, x);
|
||||
dumpByteArray(x);
|
||||
float f = doublePacked2Float(x, LSBFIRST);
|
||||
Serial.println(f / 1e38, 20); // divide prevents ovf in output
|
||||
Serial.println(f / 1e38, 20); // divide prevents overflow (ovf) in output
|
||||
dumpFloat(f);
|
||||
Serial.println();
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/IEEE754tools.git"
|
||||
},
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.5",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
"headers": "IEEE754tools.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=IEEE754tools
|
||||
version=0.2.4
|
||||
version=0.2.5
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Fast helper functions for IEEE754 floats.
|
||||
|
@ -2,8 +2,11 @@
|
||||
[![Arduino CI](https://github.com/RobTillaart/IEEE754tools/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/IEEE754tools/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/IEEE754tools/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/IEEE754tools/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/IEEE754tools/actions/workflows/jsoncheck.yml)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/IEEE754tools.svg)](https://github.com/RobTillaart/IEEE754tools/issues)
|
||||
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/IEEE754tools/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/IEEE754tools.svg?maxAge=3600)](https://github.com/RobTillaart/IEEE754tools/releases)
|
||||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/IEEE754tools.svg)](https://registry.platformio.org/libraries/robtillaart/IEEE754tools)
|
||||
|
||||
|
||||
# IEEE754tools
|
||||
@ -17,9 +20,12 @@ IEEE754tools.h contains a collection of experimental bit-hacks to speed up
|
||||
a number of operations on floating point numbers on the **Arduino UNO**.
|
||||
These bit-hacks started in 2010 (oldest code found), maybe even earlier.
|
||||
|
||||
http://en.wikipedia.org/wiki/Double_precision
|
||||
|
||||
http://en.wikipedia.org/wiki/Single-precision_floating-point_format
|
||||
#### Related
|
||||
|
||||
- http://en.wikipedia.org/wiki/Double_precision
|
||||
- http://en.wikipedia.org/wiki/Single-precision_floating-point_format
|
||||
- https://github.com/RobTillaart/float16
|
||||
|
||||
|
||||
## WARNING
|
||||
@ -45,6 +51,13 @@ ESP32 - needs investigation as UNO verified code fails.
|
||||
(something for a long winter)
|
||||
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "IEEE754tools.h"
|
||||
```
|
||||
|
||||
|
||||
## Operations
|
||||
|
||||
See examples
|
||||
@ -52,19 +65,31 @@ See examples
|
||||
|
||||
## Future
|
||||
|
||||
#### must
|
||||
#### Must
|
||||
|
||||
- improve documentation
|
||||
- test with double
|
||||
- test on ESP23
|
||||
|
||||
#### should
|
||||
- investigate other speed ups
|
||||
- bring more structure in this library.
|
||||
#### Should
|
||||
|
||||
- investigate other speed ups
|
||||
- bring more structure in this library
|
||||
|
||||
#### Could
|
||||
|
||||
#### could
|
||||
- write more examples
|
||||
- example binary transfer over Serial
|
||||
- example binary transfer over Ethernet
|
||||
- link to float16 in documentation
|
||||
|
||||
#### Wont
|
||||
|
||||
|
||||
## 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,
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "IEEE754_VERSION: %s\n", (char*) IEEE754_VERSION);
|
||||
fprintf(stderr, "IEEE754_LIB_VERSION: %s\n", (char*) IEEE754_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@ -106,4 +106,6 @@ unittest(test_all)
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user