Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d4574a

Browse files
Update 2023年12月21日-check-if-number-is-binary.md
1 parent 2896888 commit 3d4574a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎_posts/java-programs/2023-12-21-check-if-number-is-binary.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ In this tutorial, we will see a Java program to check if the given number is bin
1111

1212
We can check if the given number is binary or not by the following ways
1313

14-
1. Checking if number contains `1` or `0` digit by the reminder and divide method
14+
1. Checking if the number contains a `1` or `0` digits by the reminder and divide method
1515
2. Convert the number to String
1616

1717
## 1. Java program to check if the given number is binary or not by checking if the number contains `1` or `0` digit by the reminder and divide method
1818

19-
In the below program, we are getting each digits of the given input number one by one using the reminder method.
19+
In the below program, we are getting each digit of the given input number one by one using the reminder method.
2020

2121
If the digit is any other than the `0` and `1`, i.e. number is not Binary and it returns `false`. Otherwise, it will return `true`.
2222

@@ -55,16 +55,16 @@ public class BinaryChecker {
5555
101110001 is a binary number.
5656
```
5757

58-
## 2. Java program to check if the given number is binary or not by converting the number to String
58+
## 2. Java program to check if the given number is binary or not by converting the number to a String
5959

60-
In the below program we have used regex expression to check if the number has only `0` or `1` digits.
60+
In the below program, we have used the regex expression to check if the number has only `0` or `1` digits.
6161

6262
We can do it as follows
6363

6464
1. We are converting the given input number to a string
6565

6666
2. Using the regex pattern matcher to check whether the number string i.e. `inputStr` contains only `0` or `1` digits.
67-
3. If we found any `0` or `1` in the number, the number is binary and it returns `true`, Otherwise it returns `false`
67+
3. If we find any `0` or `1` in the number, the number is binary and it returns `true`, Otherwise it returns `false`
6868

6969
**Java Program**
7070

@@ -106,4 +106,4 @@ public class BinaryChecker2 {
106106

107107
```
108108
10110101 is a binary number.
109-
```
109+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /