当前位置:网站首页>On absolute value function in C language
On absolute value function in C language
2022-06-12 09:05:00 【Record dada I】
Make a note of C Absolute value usage in language
First : The header file #include<math.h> Or is it #include<stdlib.h>
One :
about plastic Of ( namely int type ) use abs();
eg:
// I just type in the subject , Show me how to use it
The first one is : assignment
int a=-10;
int b;
b=abs(a);
// When we are calculating
The second kind : operation
int a=10,int b=-20;
if(a>abs(b))//
{
}
Two :
about floating-point That is to say (double perhaps float) use fabs()
// I just type in the subject , Show me how to use it
// assignment
double a=-20.5;
double b;
b= fabs(a);
// operation
double a=10.25,b=-10.5;
if(fabs(a)>fabs(b))
{
}
3、 ... and :
about Long plastic surgery Of ( namely long int type ) use labs();
eg:
// I just type in the subject , Show me how to use it
The first one is : assignment
long int a=-10;
long int b;
b=labs(a);
// When we are calculating
The second kind : operation
long int a=,long int b=;
if(labs(a)>labs(b))
{
}
notes :
1. When we use these absolute value functions , Be sure to pay attention to type definitions , Be sure to pay attention to the same type , Otherwise, it is easy to swallow the number after the decimal point .
2. Call the function to add the header file , As for the function of header file , Novice can search , Easy to understand the principle .
3.long int This type of long term , In the process of our study, we use less , A lot of math can be thrown into an array in the end .
There was a lot to say , Want to finish one piece , As a result, the thought was broken after writing , When you think about it, you should add .
You are welcome to comment if you have your own opinions , Learning together , Common progress .
边栏推荐
- (node:22344) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permit
- Background position position NOUN
- MFS详解(四)——MFS管理服务器安装与配置
- Inheritance of row height
- Background position - exact units
- Résoudre le problème de demander à l'élément d'être ouvert lorsque l'unit é est ouverte et que vous n'avez pas été ouvert auparavant (peut - être fermé anormalement auparavant)
- 【字符集八】char8_t、char16_t、char32_t、wchar、char
- Problems that cannot be resolved by tar command
- Chapter 7 - more flexible location of memory addresses
- 128. 最長連續序列-哈希錶
猜你喜欢

【字符集七】汉字的宽字符码和多字节码分别是多少

node示例后台搭建

Can you migrate backwards before the first migration in the south- Can you migrate backwards to before the first migration in South?

机器学习笔记 - 循环神经网络备忘清单

xshell启动遇到“由于找不到mfc110.dll,无法继续执行代码的解决方法”

Unittest测试框架
![[character set 9] will GBK be garbled when copied to unicode?](/img/dc/c9ec4a90355d30479f23fdead4b349.png)
[character set 9] will GBK be garbled when copied to unicode?

IDEA新版UI申请方法+无测试资格使用方法及相关介绍

Background position - mixed units

Background color translucent
随机推荐
EIP-1559
(js)三位用逗号隔开,保留两位小数(or 四舍五入取整)
Use NVM to dynamically adjust the nodejs version to solve the problem that the project cannot be run and packaged because the node version is too high or too low
Problems that cannot be resolved by tar command
Priority issues
Wechat applet image saving function
Permutation (greedy strategy)
Random acquisition of 4-digit non repeated verification code
第七章-更灵活定位内存地址
Filters and listeners
分库分表会带来读扩散问题?怎么解决?
(14) Inputfield logic analysis
When the uniapp page jumps with complex data parameters.
Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays
RuntimeError:Input and parameter tensors are not at the same device, found input tensor at cuda:0 an
【字符集六】宽字符串和多字节字符互转
Chapter 7 - more flexible location of memory addresses
Analysis of 43 cases of MATLAB neural network: Chapter 7 regression of RBF Network -- Realization of nonlinear function regression
Introduction to Chang'an chain node certificate, role and authority management
(node:22344) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permit