Skip to content

Conversation

@antonioialazzo
Copy link

No description provided.

Comment on lines +9 to +10
if(n%2) binary.append(1, '1');
else binary.append(1, '0');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Una versione un po' più co,patta potrebbe essere

binary.append(1, n % 2 ? '1' : '0');

*/
string binary_converter(int n){
string binary = "";
while (n>0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Che succede se l'input è il numero 0?

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