Skip to content

Add convert from 8bit binary to hex#1

Open
femike wants to merge 1 commit intozaidt:masterfrom
femike:master
Open

Add convert from 8bit binary to hex#1
femike wants to merge 1 commit intozaidt:masterfrom
femike:master

Conversation

@femike
Copy link
Copy Markdown

@femike femike commented Nov 27, 2018

Hi, I think you will not mind if we add the ability to convert from binary to hex?

@zaidt
Copy link
Copy Markdown
Owner

zaidt commented Dec 26, 2018

Good idea! dont mind pulling the change. Just need to address the review comments


![screenshot](https://github.com/zaidt/hexbin/blob/master/resources/hexbin.png?raw=true)

For convert 8bit binary to hex write it in format:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

"To" instead of "For"

} else if (selection.length == 10 && selection.toUpperCase().substr(-10, 2) == '0B') {
bin = selection.substr(2, 10);
hex = this.bin2hex(bin);
dec = this.bin2dec(bin);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is there a specific reason why the dec needs to be re-set? the decimal value is already set at line 28 "dec = parseInt(selection);"

}
this.element.textContent = "Hex:" + hex + " Bin:" + this.formatBinary(bin) + " Dec:" + dec;
} else {
} else if (selection.length == 10 && selection.toUpperCase().substr(-10, 2) == '0B') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you please make the length variable instead of 10? i.e. a values "0b11011" should be valid. btw, line 28 "dec = parseInt(selection);" validates if the string is a number, if it fails the "if" is not entered, so you just need to check if te first 2 chars are "0b"

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