c26451 overflow 에러
조회수 1376회
Vector2(float _x = 0.0f, float _y = 0.0f) : x(_x), y(_y) {}
float Magnitude() { return (float)sqrt(x * x + y * y); }
return에서 overflow 에러났는데, 왜 문제인지, 어떻게 고쳐야하는지 모르겠어요.
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
돌려 봤는데 에러 안나는데요?
- 코드
#include <iostream> using namespace std; class Vector2 { public: Vector2(float _x = 0.0f, float _y = 0.0f) : x(_x), y(_y) {} float Magnitude() { return (float)sqrt(x * x + y * y); } private: float x{ 0 }; float y{ 0 }; }; int main() { Vector2 a; Vector2 b{ 3,-3 }; Vector2 c{ numeric_limits<float>::max(),numeric_limits<float>::max() }; cout << a.Magnitude() << '\n'; cout << b.Magnitude() << '\n'; cout << c.Magnitude() << '\n'; }
- 결과
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력