Tag: math.h

C – 简单的数学论证不起作用?

我只想用一个相对简单的公式来计算10年的金额。 我可以输入我的所有变量,但我怀疑我的amount 。 #include #include int main(){ double amount; /* amount on deposit */ double principal; /* what’s the principal */ double rate; /* annual interest rate */ int year; /* year placeholder and no. of total years */ int yearNo; printf(“What is the principal? “); scanf(“%d”, &principal); printf(“What is the rate (in decimal)? “); […]

在C中以更高的精度存储数字

我正在编写一个程序,其中我需要以非常高的精度(大约10^-10 )存储数字,然后进一步使用它们参数( create_bloomfilter ([yet to decide the type] falsePositivity, long expected_num_of_elem) )。 我能得到的最高精度是double (大约10^-6 )这是不够的。 我们如何在c中存储更高精度的数字?

Turbo C编译器问题,sqrt()函数不能使用变量参数

我搜索类似于我的问题类似的问题 。 但我的问题是使用Turbo C编译器v3.0时。 我是否应该为math.h文件做一些额外的工作? 请帮忙。 int main (void){ double result, a; clrscr(); printf(“Enter a # for square root.\n”); scanf(“%f”,&a); printf(“a = %f\n”,a); result = sqrt(a); printf(“a = %f and square root is %f\n”,a, result); getch(); return 0; } 输出是这样的: 输入#作为平方根。 64 a = 0.000000 a = 0.000000,平方根为0.000000

c等于matlab的sind和cosd函数

所以我正在使用一些matlab代码手动转换为c代码。 我只是想知道是否有相当于我在matlab代码中看到的sind和cosd函数的交流。 我想这会以度为单位返回答案而不是以弧度为单位给出结果的c sin和cos函数。 我想我可以将结果乘以180 / pi,但只是想知道math.h中是否有库函数我没有看到。 或者即使gsl库中有某些内容可以执行此操作。

浮点再次

昨天我问了一个浮点问题,我有另一个问题。 我正在做一些计算,我使用math.h(C语言)正弦,余弦和正切函数的结果。 其中一位开发人员喃喃地说,你必须小心这些函数的返回值,我不应该对gcc数学函数的返回值做出假设。 我不是想开始讨论,但我真的想知道在使用标准数学函数进行计算时需要注意什么。 X

数学库现在是否包含在glibc中?

当我尝试从终端编译这个简单的代码时: #include int main(void) { printf(“%f\n”,sqrt(10)); return 0; } 运用 gcc main.c 命令,它被编译,a.out给出正确的答案。 这意味着数学函数被添加到C标准库中,它自动链接。 但是如果在Eclipse IDE中编译相同的代码而不向属性添加任何库,则会给出未定义的引用错误。 这意味着数学函数不是C标准库的一部分。 真相是什么?

使用cmath 时禁用math.h废话

之前我遇到了一个问题,因为函数在没有std::情况下被重载。 诅咒仍然时不时发生,因为我不使用using namespace std; 。 删除使用命名空间std会导致程序获得废话结果 有没有办法禁用所有来自c的非std函数,只能在命名空间std下使用c ++函数(不必using namespace std; )? 换句话说:如果我使用sin()而不是std::sin() ,我想得到一个错误,这样我就不会犯这个错误。 当然,不仅是罪,而且是与math.h发生冲突的每一个function。

C中的powfunction

我编写了一个具有power.h函数的C代码,该代码来自math.h库。 当我编译我的程序时,我收到一个错误,即“未定义引用’pow’函数”,我使用gcc编译器(fedora 9)编译我的程序。 我将-lm标志插入gcc然后,错误被省略,但pow函数的输出为0。 #include main() { double a = 4, b = 2; b = pow(b,a); } 谁能帮我? 我的编译器有问题吗? 谢谢。

包含math.h后的abs’隐式声明…’错误

我使用了abs()函数,并在代码顶部添加了#include 。 但我一直收到这个错误: hello.c:20:11: warning: implicit declaration of function ‘abs’ is invalid in C99 [-Wimplicit-function-declaration] int a = abs(arrOfHour[i] – hour) * 60 + minute; ^ 我正在使用LLVM编译器。 即使我已经包含了math.h为什么会出现这个错误?

C:对地板的未定义参考

我在Ubuntu上使用Eclipse来编写/编译/运行C代码。 我正在尝试构建我的项目。 以下是Eclipse控制台中的输出。 22:18:31 **** Build of configuration Debug for project Project1 **** make all Building file: ../project1.c Invoking: GCC C Compiler gcc -I/lib/i386-linux-gnu -O0 -g3 -Wall -c -fmessage-length=0 -pthread -lm -MMD -MP -MF”project1.d” -MT”project1.d” -o “project1.o” “../project1.c” ../project1.c: In function ‘main’: ../project1.c:146:6: warning: unused variable ‘this_thread_id’ [-Wunused-variable] ../project1.c: In function ‘_pre_init’: ../project1.c:126:1: warning: control […]