Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/core/basesyntax/BinaryString.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ public class BinaryString {
* Напишите метод toBinaryString(), который принимает на вход целое число value,
* а возвращает String с представлением этого числа в двоичном виде.
*/
public String toBinaryString(int value) {
return null;
String toBinaryString(int value) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

next time don't change method signature

int result = 0;
int digitCounter = 0;
while (value > 0) {
result += value % 2 * Math.pow(10, digitCounter);
value = value / 2;
digitCounter++;
}
return String.valueOf(result);
}
}