小编use*_*189的帖子

乘法浮点数给出无限值

我尝试了很多方法:

float a = 1234.34;
float b = 1234.52;
float r = a * b;
cout << r << endl;
float c = 1234.34 * 1234.52;
cout << c << endl;

cout << 1234.34 * 1234.52 << endl;
cout << (float)(1234.34 * 1234.52) << endl;
Run Code Online (Sandbox Code Playgroud)

所有这些似乎都给出了无限的价值......

1.52382e+006
1.52382e+006
1.52382e+006
1.52382e+006
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

c++ multiplication

1
推荐指数
1
解决办法
571
查看次数

Error when Overloading the operator <<

_3DTocka operator<<(ostream& os, _3DTocka _3D){
    cout << "(" << _3D.x << "," << _3D.y << "," << _3D.z << ")" << endl;
}
Run Code Online (Sandbox Code Playgroud)

The above is my code and it gives an error: it must take exactly one argument (1 line)

_3DTocka is the name of the class..

c++ class operator-overloading

0
推荐指数
1
解决办法
42
查看次数

标签 统计

c++ ×2

class ×1

multiplication ×1

operator-overloading ×1