Skip to content

50. Pow(x, n)#45

Open
dxxsxsxkx wants to merge 1 commit into1011_capacity_to_ship_packages_within_d_daysfrom
50_pow_xn
Open

50. Pow(x, n)#45
dxxsxsxkx wants to merge 1 commit into1011_capacity_to_ship_packages_within_d_daysfrom
50_pow_xn

Conversation

@dxxsxsxkx
Copy link
Copy Markdown
Owner

long_abs_n /= 2;
}

if (n < 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自分は n < 0 の場合を関数の上のほうで処理し、 std::abs() を消すほうが好きですが、好みの範囲だと思います。

}

int64_t long_n = n;
int64_t long_abs_n = std::abs(long_n);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++に詳しくないのですが、long_n はもう使わないので、absを取るときにキャストするのではどうでしょうか。また、int64_t にしなければならない背景をコメントしておくとよいと思いました。

Suggested change
int64_t long_abs_n = std::abs(long_n);
int64_t abs_n = std::abs(static_cast<int64_t>(long_n));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants