JAVA
PROGRAM TO ADD TWO BINARY NUMBERS
When two binary strings are added, the result is also a binary string. Java provides multiple ways to perform binary addition, depending on constraints such as input size and performance requirements.
Example:
Input : x = "110", y = "011"
Output: "1001"
Explanation:
110
- 011 =1001
class GFG {
static String addBinary(String x, String y) {
int num1 = Integer.parseInt(x, 2);
int num2 = Integer.parseInt(y, 2);
int sum = num1 + num2;
return Integer.toBinaryString(sum);
}
public static void main(String[] args) {
String x = "011011";
String y = "1010111";
System.out.println(addBinary(x, y));
}
}
Output
1110010
Limitations:
Works only when values fit within integer range
Not suitable for very large binary strings
SQL
What is a NULL Value?
If a field in a table is optional, it is possible to insert or update a record without adding any value to this field. This way, the field will be saved with a NULL value.
A NULL value represents an unknown, missing, or inapplicable data in a database field. It is not a value itself, but a placeholder to indicate the absence of data.
Note: A NULL value is different from zero (0) or an empty string (''). A field with a NULL value is one that has been left blank upon record creation.
How to Test for NULL Values?
It is not possible to test for NULL values with comparison operators, such as =, <, or <>.
We will have to use the IS NULL and IS NOT NULL operators instead.
IS NULL Syntax
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
SELECT CustomerName, ContactName, Address
FROM Customers
WHERE Address IS NULL;
References
https://www.w3schools.com/sql/sql_null_values.asp
https://www.geeksforgeeks.org/java/java-program-to-add-two-binary-strings/
Top comments (0)