'Unable to compile IEEE754 intel library
I am stuggling with IEEE754 intel library which I want to use in my calculator project on Raspberry pico. I want to compute with 128-bit decimal floating-point numbers.
This library is quite large for Raspberry pico so I planned to use only source files with functions I need (+, -, *, /, sqrt, sin, cos, log, ...).
It is this library: IEE754 intel library
First I managed to make to work add, sub, mul, div and sqrt.
This files are needed:
- bid128.c
- bid128_2_str.h
- bid128_2_str_macros.h
- bid128_2_str_tables.c
- bid128_add.c
- bid128_fma.c
- bid128_mul.c
- bid128_sqrt.c
- bid128_string.c
- bid_conf.h
- bid_decimal_data.c
- bid_functions.h
- bid_internal.h
- bid_round.c
- bid_sqrt_macros.h
- bid_trans.h
- decimal.h
And here is the code:
#include "decimal.h"
BID_UINT128 a, b, c;
char output_IEEE[] = " ";
_IDEC_round my_rnd_mode = _IDEC_dflround;
_IDEC_flags my_fpsf = _IDEC_allflagsclear;
void setup()
{
Serial.begin(115200);
delay(5000);
char input_a[] = {'+', '0', '.', '1', '2', 'E', '-', '1', '2', 0};
char input_b[] = {'3', '.', '1', '4', '1', 0};
a = __bid128_from_string (input_a, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, a, &my_fpsf);
Serial.println("a = " + String(output_IEEE));
b = __bid128_from_string (input_b, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, b, &my_fpsf);
Serial.println("b = " + String(output_IEEE));
my_rnd_mode = _IDEC_nearesteven; my_fpsf = _IDEC_allflagsclear;
c = __bid128_add (a, b, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, c, &my_fpsf);
Serial.println("a + b = " + String(output_IEEE));
c = __bid128_mul (a, b, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, c, &my_fpsf);
Serial.println("a * b = " + String(output_IEEE));
c = __bid128_sqrt (a, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, c, &my_fpsf);
Serial.println("sqrt(a) = " + String(output_IEEE));
}
I get this output which is exactly what I want:
a = +12E-14
b = +3141E-3
a + b = +314100000000012E-14
a * b = +37692E-17 sqrt(a) = +3464101615137754587054892683011745E-40
but when I want to compute transcendental with this file bid128_sin.c added:
c = __bid128_sin (a, my_rnd_mode, &my_fpsf);
__bid128_to_string (output_IEEE, c, &my_fpsf);
Serial.println("sqrt(a) = " + String(output_IEEE));
I must include a lot of another source files and headers and the more I add the more errors arise.
Has someone experience with this library, please. I don't want to compile the whole library because it would be too big for the raspberry pico. I am also unable to get those "transcendental" functions to work on windows.
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
