如何使用C 获取周期十进加点号的平方根
How to get the square root of a periodic decimal point number using C++?
当我尝试获得周期十进制数字的平方根时,结果为 0
。
示例代码:
sqrt(4/99)
准确性并不重要,可以截断一些数字。
您使用整数作为sqrt()
函数的输入。
#include <cmath>
#include <iostream>
int main(int argc, char** argv)
{
std::cout << std::sqrt(4 / 99) << std::endl;
std::cout << std::sqrt(4.0 / 99) << std::endl;
}
Output
0
0.201008
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- C++:TypeDef使用元组
- 使用std::multimap迭代器创建std::list
- 从不同线程使用int64的不同字节安全吗
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- 为什么在全局范围内使用"extern int a"似乎不行?
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 使用二分法查找数的平方根时出现问题
- 如何使用C 获取周期十进加点号的平方根
- 使用位移算法计算平方根始终输出相同的数字
- 使用 LLVM 的 libc++ 时,__1 符号从何而来?
- 在std::cout之后使用std::cin时,换行符从何而来
- 编写代码以在 C++ 中使用二分法查找平方根
- 我使用 x=a+x-x^2 并设置 g(x)=a+x-x^2 来找到正参数 a 的正平方根
- 为什么以及在何处在C++中使用引用和指针
- 使用平方根的偶数除数
- 如何在不使用平方根的情况下检查一个整数是否是完全平方数
- 如何通过使用I = I +1而不是I = I +2的while循环来打印前25个整数的平方根?
- 基例如何影响使用递归函数的哪些行