-
Notifications
You must be signed in to change notification settings - Fork 125
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
Create Binary To Decimal Converter.js #456
base: main
Are you sure you want to change the base?
Create Binary To Decimal Converter.js #456
Conversation
This parser is a Binary to Decimal Converter designed to parse user input in a specific format and convert binary values to decimal. By providing a command with a binary code, this parser uses an external API to fetch and return the decimal equivalent. Activation Example To use this converter, simply enter the command in this format: !converttoDecimal <binary_code> For example: !converttoDecimal 1011 Features Regex-based Command Parsing: The parser validates the input command using a regular expression, ensuring only binary codes are accepted. Binary Validation: It checks the user input for valid binary numbers. API Call for Conversion: It uses the https://networkcalc.com/api/binary/<binary_code> API to convert binary to decimal. Slackbot Integration: Once the conversion is complete, the decimal value is sent back to the user in formatted message. *Binary to Decimal Conversion:* • Binary value: 1011 • Decimal value: 11
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.
Thanks for your contribution. I have applied the hacktoberfest-accepted
label which will mark this PR as accepted for you. However, there is a few changes that would be required before we can merge this.
activation_example:!converttoDecimal <binary_code> | ||
regex:^!converttoDecimal |
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.
Please remove this capitalisation, as this adds confusion when compared to all other parsers. Additionally, it is not clear that this parser converts from binary to decimal. It might be worthwhile making it something like !bin2dec
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.
ok I wil make changes
var match = input.match(/!converttoDecimal (\d+)/); // check input format | ||
var expression = match ? match[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.
It's not clear from other details about this parser, that this will not support multiple bytes (i.e. 00110101 11111111
) or breaks in the binary
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.
Ok I will rectify the code
// check the valid binary code in if statement | ||
if(binaryCheckregx.test(expression)){ | ||
var result = evaluateBinaryExpression(expression); // call to evaluateBinaryExpression | ||
var DecimalresultSlackMessage = "* Binary to Decimal Conversion :*\n" + "• *Binary value*: " + expression + "\n" + "• *Decimal value*: " + result.converted + "\n"; // slack markdown message format |
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.
This does not use unordered lists so does not use slack markdown
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.
ok
Resolve the Issue raised 1) Please remove this capitalisation, as this adds confusion when compared to all other parsers. Additionally, it is not clear that this parser converts from binary to decimal. It might be worthwhile making it something like !bin2dec 2) It's not clear from other details about this parser, that this will not support multiple bytes (i.e. 00110101 11111111) or breaks in the binary 3) This does not use unordered lists so does not use slack markdown Now, this parser will accept the binary code with spaces and give output as a decimal value. Change the activation to !bin2dec <binary code> and also remove the slack markdown and show output as normal text.
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.
I make some changes in the file. Please review the changes and accept it.
This parser is a Binary to Decimal Converter designed to parse user input in a specific format and convert binary values to decimal. By providing a command with a binary code, this parser uses an external API to fetch and return the decimal equivalent.
Activation Example
To use this converter, simply enter the command in this format:
!converttoDecimal <binary_code>
For example:
!converttoDecimal 1011
Features
Regex-based Command Parsing: The parser validates the input command using a regular expression, ensuring only binary codes are accepted.
Binary Validation: It checks the user input for valid binary numbers.
API Call for Conversion: It uses the https://networkcalc.com/api/binary/<binary_code> API to convert binary to decimal.
Slackbot Integration: Once the conversion is complete, the decimal value is sent back to the user in formatted message.
Binary to Decimal Conversion:
• Binary value: 1011
• Decimal value: 11