Skip to content

Commit 445058d

Browse files
authored
update library.json, minor edits, license (#6)
1 parent a2fdd9b commit 445058d

15 files changed

Lines changed: 55 additions & 35 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015-2021 Rob Tillaart
3+
Copyright (c) 2015-2022 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Arduino library to implement float16 data type.
1414

1515
## Description
1616

17-
This **experimental** library defines the float16 (2 byte) data type, including conversion
17+
This **experimental** library defines the float16 (2 byte) data type, including conversion
1818
function to and from float32 type. It is definitely **work in progress**.
1919

20-
The library implements the **Printable** interface so one can directly print the
20+
The library implements the **Printable** interface so one can directly print the
2121
float16 values in any stream e.g. Serial.
2222

23-
The primary usage of the float16 data type is to efficiently store and transport
24-
a floating point number. As it uses only 2 bytes where float and double have typical
23+
The primary usage of the float16 data type is to efficiently store and transport
24+
a floating point number. As it uses only 2 bytes where float and double have typical
2525
4 and 8 bytes, gains can be made at the price of range and precision.
2626

2727

@@ -31,13 +31,39 @@ a floating point number. As it uses only 2 bytes where float and double have typ
3131
| attribute | value | notes |
3232
|:----------|:-------------|:--------|
3333
| size | 2 bytes | layout s eeeee mmmmmmmmmm
34-
| sign | 1 bit |
35-
| exponent | 5 bit |
36-
| mantissa | 11 bit | ~ 3 digits
37-
| minimum | 5.96046 E−8 | smallest positive number.
38-
| | 1.0009765625 | 1 + 2^−10 = smallest nr larger than 1.
39-
| maximum | 65504 |
40-
| | |
34+
| sign | 1 bit |
35+
| exponent | 5 bit |
36+
| mantissa | 11 bit | ~ 3 digits
37+
| minimum | 5.96046 E−8 | smallest positive number.
38+
| | 1.0009765625 | 1 + 2^−10 = smallest nr larger than 1.
39+
| maximum | 65504 |
40+
| | |
41+
42+
43+
#### example values
44+
45+
```cpp
46+
/*
47+
SIGN EXP MANTISSA
48+
0 01111 0000000000 = 1
49+
0 01111 0000000001 = 1 + 2−10 = 1.0009765625 (next smallest float after 1)
50+
1 10000 0000000000 = −2
51+
52+
0 11110 1111111111 = 65504 (max half precision)
53+
54+
0 00001 0000000000 = 2−14 ≈ 6.10352 × 10−5 (minimum positive normal)
55+
0 00000 1111111111 = 2−14 - 2−24 ≈ 6.09756 × 10−5 (maximum subnormal)
56+
0 00000 0000000001 = 2−24 ≈ 5.96046 × 10−8 (minimum positive subnormal)
57+
58+
0 00000 0000000000 = 0
59+
1 00000 0000000000 = −0
60+
61+
0 11111 0000000000 = infinity
62+
1 11111 0000000000 = −infinity
63+
64+
0 01101 0101010101 = 0.333251953125 ≈ 1/3
65+
*/
66+
```
4167

4268

4369
## Interface
@@ -66,7 +92,7 @@ See array example for efficient storage using set/getBinary() functions.
6692

6793
#### Compare
6894

69-
Standard compare functions. Since 0.1.5 these are quite optimized,
95+
Standard compare functions. Since 0.1.5 these are quite optimized,
7096
so it is fast to compare e.g. 2 measurements.
7197

7298
- **bool operator == (const float16& f)**
@@ -80,7 +106,7 @@ so it is fast to compare e.g. 2 measurements.
80106
#### Math (basic)
81107

82108
Math is done by converting to double, do the math and convert back.
83-
These operators are added for convenience only.
109+
These operators are added for convenience only.
84110
Not planned to optimize these.
85111

86112
- **float16 operator + (const float16& f)**
@@ -106,7 +132,7 @@ negation operator.
106132
## Future
107133

108134

109-
#### 0.1.6
135+
#### 0.1.x
110136

111137
- update documentation.
112138
- unit tests of the above.

examples/float16_test0/float16_test0.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
//
22
// FILE: float16_test0.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2015-03-11
76
// URL: https://github.com/RobTillaart/float16
87
//
98

10-
119
/*
1210
SIGN EXP MANTISSA
1311
0 01111 0000000000 = 1
@@ -29,6 +27,7 @@
2927
0 01101 0101010101 = 0.333251953125 ≈ 1/3
3028
*/
3129

30+
3231
#include "float16.h"
3332

3433

examples/float16_test1/float16_test1.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test1.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2015-03-11
76
// URL: https://github.com/RobTillaart/float16

examples/float16_test_all/float16_test_all.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test_all.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2021-11-27
76
// URL: https://github.com/RobTillaart/float16

examples/float16_test_array/float16_test_array.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test_array.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2015-03-11
76
// URL: https://github.com/RobTillaart/float16

examples/float16_test_negative/float16_test_negative.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test_negative.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2021-11-26
76
// URL: https://github.com/RobTillaart/float16

examples/float16_test_performance/float16_test_performance.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test_performance.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2021-11-26
76
// URL: https://github.com/RobTillaart/float16
@@ -15,6 +14,7 @@ uint32_t start, stop;
1514
volatile float f;
1615
volatile bool b;
1716

17+
1818
void setup()
1919
{
2020
while (!Serial);

examples/float16_test_powers2/float16_test_powers2.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: float16_test_powers2.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2015-03-11
76
// URL: https://github.com/RobTillaart/float16

examples/float16_test_special/float16_test_special.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
//
22
// FILE: float16_test_special.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: test float16
65
// DATE: 2021-11-26
76
// URL: https://github.com/RobTillaart/float16
8-
//
97

108
// test special values ...
119
// https://github.com/RobTillaart/float16/issues/2
1210

1311

1412
#include "float16.h"
1513

14+
1615
uint16_t value[32] =
1716
{
1817
0xFC00, 0xF400, 0xEC00, 0xE400, 0xDC00, 0xD400, 0xCC00, 0xC400,

0 commit comments

Comments
 (0)