无法编译IEEE754英特尔库

发布于 2025-01-30 10:32:39 字数 2790 浏览 1 评论 0 原文

我正在与IEEE754 Intel库中脱颖而出,该图书馆想在Raspberry Pico上的计算器项目中使用。我想用128位小数浮点数计算。

对于Raspberry Pico,该库非常大,因此我计划仅使用具有我需要的函数的源文件(+, - , *, /,SQRT,SIN,COS,cos,log,...)。

这是这个库:

首先,我设法使工作 add sub mul div SQRT
需要

  • BID128.C
  • BID128_2_STR.H
  • BID128_2_2_STR_MACROS.H
  • BID128_2_2_2_STR_TABLE.C
  • BID128_ADD.C
  • BID128_FMA.C
  • BID128_FMA.C
  • BID128_MUL.C
  • BID128_SSQRT.CBIIM_CBIIM_C.C.C
  • .
  • bid_functions.h
  • bid_internal.h
  • bid_round.c
  • bid_sqrt_macros.h
  • BID_TRANS.H
  • DECIMAL.H

,这是代码:

#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)); 

}

我得到此输出,这正是我想要的:

a = +12e-14
B = +3141E-3
A + B = + 31410000000000012E-14
A * B = +37692E-17 SQRT(A)= +346410161513775458705454892683011745E-40

,但是当我想用该文件 bid> bid128_sin.sin.c 添加了一个文件时,

  c = __bid128_sin (a, my_rnd_mode, &my_fpsf);
  __bid128_to_string (output_IEEE, c, &my_fpsf); 
  Serial.println("sqrt(a) = " + String(output_IEEE)); 

我必须添加一个pote and pose and pose :而且我添加越多,出现的错误就会出现更多。
请有人在这个图书馆经验。我不想编译整个图书馆,因为对于覆盆子Pico来说,它太大了。我也无法使这些“ 超越”功能在Windows上工作。
谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文