Closed johannes-777 closed 2 years ago
Just ported to GCC and found one more:
Hi @johannes-777
That float16 library was an experiment and never finished, properly tested or published on GitHub. Think you got it from the Arduino forum.
A quick look in my library folder show that the date of the .h file is march 2015 (6+yrs ago). So too long ago to have an educated clue.
That said I notice that all failing numbers are powers of 2. So expect there is a single underlying bug. Gut feeling says the exponent is set 1 too high/low which might point at a < that should be <= or so.
I can setup a repo for this library - labeled experimental. As I have quite some work already it would be low in priority. I vaguely recall it was not the easiest code I worked with, so it needs focus (== time). Having a repo would at least bring development in some structured process, that would allow others to help to get it working.
Would that be an idea?
Hi Rob, I absolutely agree, this lib required quite some attention. I found the problem here:
exp <<= 10; //man++; -> Leads to rounding issues (e.g. 7.999300,31.992901, 511.911591 ...) : https://github.com/RobTillaart/Arduino/issues/176 man >>= 1; f16_bin= (sgn ? 0x8000 : 0x0000) | exp | man;
Max Error to f32 is 0.096%, which is acceptable for 10 bit mantissa (fraction), even though it may be improved by smarter rounding.
I will create a repro - do you have a version number of the version you use as a start point?
https://github.com/RobTillaart/float16
will fill it with build-CI files so we can have some automated tests and examples
update
There is still a lot todo but we have a starting point.
I transfer this issue to the float16 repo.
@johannes-777 Merged the first pull request to have a new starting point. (did not make a release 0.1.4 yet)
merged into master
@johannes-777
A test over the whole f16 numberspace revealed issues with certain numbers, where the error to f32 is 50%. Examples: F32 is -32764.726562, F16 is -16384.000000 -> error is -50.00%! F16 encoding: 0xF400 F32 is -31.996500, F16 is -16.000000 -> error is -49.99%! F16 encoding: 0xCC00 ...
Can you please check if the last master branch still shows this issue? (or share the sketch so I can verify)
0.1.4 will be released asap, so it can be published and tested in a broader audience.
done added to the Arduino library manager. published on https://platformio.org/lib/show/13206/float16
@johannes-777 0.1.5 in PR
@johannes-777
FYI, today I reworked the float16 library to fix a bug (issue #10) and correct the implementation of subnormal numbers (< 0.00006...) Just to let you know. The new version 0.2.0 will be released later this week.
Hi Rob, I have Float16 Lib from you but couldn't find it in your repos. I found 2 issues:
f32tof16 should use
A test over the whole f16 numberspace revealed issues with certain numbers, where the error to f32 is 50%.
Examples:
Do you have any ideas? I am using ESP32