-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pow method finished in CustomMathPow class #16
base: master
Are you sure you want to change the base?
pow method finished in CustomMathPow class #16
Conversation
*/ | ||
public int pow(int number, int exponential) { | ||
return 0; | ||
double result = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NikolayKatsai why you are using double here?
for (int i = 0; i < exponential; i++) { | ||
result *= number; | ||
if (result < 0) { | ||
return 2147483647; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NikolayKatsai why are you returning this number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2147483647 максимальне значення інта, а в тестах приходять данні які переповнюють інт, і як відповідь тест очікує саме максимальне значення інта, тому його і повертаю))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Це не корректна поведінка. Якщо є помилка в тестах - то необхідно виправити тест, а не підганяти імплементацію. Це порада на майбутнє
No description provided.