Skip to content

Hw 3#152

Open
YaTut1901 wants to merge 4 commits into
mate-academy:masterfrom
YaTut1901:hw-3
Open

Hw 3#152
YaTut1901 wants to merge 4 commits into
mate-academy:masterfrom
YaTut1901:hw-3

Conversation

@YaTut1901

Copy link
Copy Markdown

No description provided.

}
StringBuilder builder = new StringBuilder("");
int remainder = 0;
while (value >= 1) {

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.

let's change the condition to value >= 0, and then you can remove if statement

builder.append(1);
break;
} else {
remainder = value % 2;

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.

do we need remainder local variable? let's remove it)

StringBuilder builder = new StringBuilder("");
while (value > 0.5) {
builder.append(value % 2);
value = Math.round(value / 2);

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.

Suggested change
value = Math.round(value / 2);
value = value / 2;

return "0";
}
StringBuilder builder = new StringBuilder("");
while (value > 0.5) {

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.

Suggested change
while (value > 0.5) {
while (value > 0) {

if (value == 0) {
return "0";
}
StringBuilder builder = new StringBuilder("");

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.

Suggested change
StringBuilder builder = new StringBuilder("");
StringBuilder builder = new StringBuilder();

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.

2 participants