float 的精度是7位。double精度可以保证15位。
但是默认float和double都只能显示6位小数部分,
再多需要#include <iomanip>,
然后在输出语句之前插入cout << setprecision(20);强制输出小数位。
double类型占8个字节——>sizeof(ff*dd)= 8
int类型占4字节
- cout <<(double)x / y ;是把 x 强制转换成double类型,再和 y 做除法运算。不是x和y先除,再把结果强制转换
- int(‘A’)是把字符A 转成内码值
Arithmetic operators are fundamental operators in programming that allow you to perform various mathematical calculations on numerical values. These operators are used to carry out basic arithmetic operations like addition, subtraction, multiplication, division, and more. Here's an overview of the common arithmetic operators:
1. Addition (+): Adds two numerical values together.
```python
result = 5 + 3 # result will be 8
```
2. Subtraction (-):Subtracts the right operand from the left operand.
```python
result = 10 - 4 # result will be 6
```
3. Multiplication (*): Multiplies two numerical values together.
```python
result = 7 * 2 # result will be 14
```
4. Division (/): Divides the left operand by the right operand. In many programming languages, if both operands are integers, division between them will result in an integer division (floor division), while using at least one floating-point operand will yield a floating-point result.
```python
result = 15 / 4 # result will be approximately 3.75
```
5. Modulus (%):Returns the remainder when the left operand is divided by the right operand.
```python
result = 20 % 3 # result will be 2 (20 divided by 3 leaves a remainder of 2)
```
6. Exponentiation ( or ^, depending on the programming language):Raises the left operand to the power of the right operand.
```python
result = 2 ** 3 # result will be 8 (2 raised to the power of 3)
```
7. Floor Division (//):Performs integer division, resulting in the quotient without the remainder.
```python
result = 15 // 4 # result will be 3 (integer division of 15 by 4)
```
These arithmetic operators are used extensively in programming to perform calculations and manipulate numerical values. They can be combined and used within expressions to create more complex mathematical operations. It's important to remember operator precedence (the order in which operators are evaluated) and to use parentheses when necessary to ensure the desired order of operations.