In C#
I want to Check the value which is in 8 bit Binary format (i.e. 0000000a or 00010ef0) is between the specific range....
for example (following is C language code )
int temp=5;
if (temp>=0 || temp<10)
printf("temp is between 0-10");
same way i want to check Hexadecimal value is in Given rage or not ....
<< is the left shift operator. It is shifting the number 1 to the left 0 bits, which is equivalent to the number 1 .
%d is a format specifier, used in C Language. Now a format specifier is indicated by a % (percentage symbol) before the letter describing it. In simple words, a format specifier tells us the type of data to store and print. Now, %d represents the signed decimal integer.
The && (logical AND) operator indicates whether both operands are true. If both operands have nonzero values, the result has the value 1 . Otherwise, the result has the value 0 . The type of the result is int . Both operands must have an arithmetic or pointer type.
You can convert the string of the hex value to an integer
int hexvalue = int.Parse(value.ToString(),System.Globalization.NumberStyles.HexNumber);
and then do your normal test
if (hexvalue >=0 || hexvalue <10)
Console.WriteLine("hexvalue is between 0-10");
You may use int family types:
int val=0x19;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With