The Float.isInfinite() method in Java returns true if this Float value is infinitely large in magnitude, else false is returned.We have the following Float valuesFloat f1 = new Float(5.0/0.0); Float f2 = new Float(10.2/0.0); Float f3 = new Float(0.0/0.0);Check with isInfinite() methodf1.isInfinite(); f2.isInfinite(); f3.isInfinite();The following is the complete example with output −Example Live Demoimport java.lang.*; public class Demo { public static void main(String args[]) { Float f1 = new Float(5.0/0.0); Float f2 = new Float(10.2/0.0); Float f3 = new Float(0.0/0.0); System.out.println(f1.isInfinite()); System.out.println(f2.isInfinite()); System.out.println(f3.isInfinite()); } }Outputtrue true false
In 8051 Microcontroller there is 17 different instructions under the Logical Group. In total there are 46 opcodes. These instructions do not affect the flag bits but the CJNE affects the CY flag. In these instructions, the 11-bit address and 16-bit addresses are used.In the following table, we will see the Mnemonics, Lengths, Execution Time in terms of the machine cycle, Number of Opcodes etc.MnemonicsByte CountExecutionTimeOpcode CountACALL addr11228LCALL addr16321RET121RETI121AJMP addr11228LJMP addr16321SJMP rel221JMP @A+DPTR121JZ rel221JNZ rel221CJNE A, a8, rel321CJNE A, #d8, rel321CJNE Rn, #d8, rel328CJNE @Ri, #d8, rel322DJNE Rn, rel228DJNZ a8, rel321NOP111ExamplesSr.NoInstruction & Description1LJMP LABELThis is an example of LJMP addr16. ... Read More
Use the getTimeInstance() method in Java to get the time format for the locale you have set. DateFormat.LONG is a constant for long style pattern.Firstly, we will create Date objectDate dt = new Date(); DateFormat dateFormat;Let us format time for different locale with DateFormat.LONGdateFormat = DateFormat.getTimeInstance(DateFormat.LONG, Locale.FRENCH); System.out.println("Locale FRENCH = " + dateFormat.format(dt)); dateFormat = DateFormat.getTimeInstance(DateFormat.LONG, Locale.GERMANY); System.out.println("Locale GERMANY = " + dateFormat.format(dt)); dateFormat = DateFormat.getTimeInstance(DateFormat.LONG, Locale.CHINESE); System.out.println("Locale CHINESE = " + dateFormat.format(dt));The following is an example −Example Live Demoimport java.text.DateFormat; import java.util.Date; import java.util.Locale; public class Demo { public static void main(String args[]) { Date dt ... Read More
Here we will see a problem to shift some multi-byte BCD number to the right. The BCD numbers are shifted by two digits (8-bit). Let us consider a four-byte BCD number (45 86 02 78) is stored at location 20H, 21H, 22H, 23H. The address 10H holds the number of bytes of the whole BCD number. So after executing this code, the contents will be shifted to the right and 20H will hold 00H.AddressValue...20H4521H8622H0223H78...Program CLRA;Clear the Register A MOVR2, 10H;TakeByte Count INCR2;Increase R2 for loop MOVR1, ... Read More
Use the getTimeInstance() method in Java to get the time format for the locale you have set. DateFormat.FULL is a constant for full style pattern.Firstly, we will create Date objectDate dt = new Date(); DateFormat dateFormat;Let us format time for different locale with DateFormat.FULLdateFormat = DateFormat.getTimeInstance(DateFormat.FULL, Locale.CHINESE); System.out.println("Locale CHINESE = " + dateFormat.format(dt)); dateFormat = DateFormat.getTimeInstance(DateFormat.FULL, Locale.CANADA); System.out.println("Locale CANADA = " + dateFormat.format(dt)); dateFormat = DateFormat.getTimeInstance(DateFormat.FULL, Locale.ITALY); System.out.println("Locale ITALY = " + dateFormat.format(dt));The following is an example −Example Live Demoimport java.text.DateFormat; import java.util.Date; import java.util.Locale; public class Demo { public static void main(String args[]) { Date dt ... Read More
In this problem, we will see how to convert an 8-bit binary number to its BCD equivalent. The binary number is stored at location 20H. After converting, the results will be stored at 30H and 31H. The 30H will hold the MS portion, and 31H will hold the LS portion. So let us assume the data is D5H. The program converts the binary value of D5H to BCD value 213D.AddressValue...20HD521H...ProgramMOVR1, #20H;Takethe address 20H into R1 MOVA, @R1;Takethe data into Acc MOVB, #0AH;LoadB with AH = 10D DIVAB ;DivideA with B MOVR5, B;Storethe remainder MOVB, #0AH;LoadB with AH = 10D DIVAB ;DivideA ... Read More
In this problem, we will see how to convert 8-bit BCD number to its Binary (Hexadecimal)equivalent. The BCD number is stored at location 20H. After converting, the results will be stored at 30H.So let us assume the data is D5H. The program converts the binary value ofD5H to BCD value 213D.AddressValue...20H9421H...Program MOVR0, #20H; Initialize the address of the data MOVA, @R0;Get the data from an address, which is stored in R0 MOVR2, A; Store the content of A into R2 CLRA;Clear the content of A to 00H MOVR3, #00H LOOP: ADDA, #01H;increment A ... Read More
Now we will see how to convert Hexadecimal number to its ASCII equivalent using 8051. This program can convert 0-9 and A-F to its ASCII value. We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is39H (57D). So all other numbers are in the range 30H to 39H. The ASCII value of 0AH is 41H (65D) and ASCII of 0FH is 46H (70D), so all other alphabets (B, C, D, E) are in the range 41H to 46H.Here we are providing hexadecimal digit at memory location 20H, The ASCII equivalent is storing at location 30H.AddressValue...20H0EH21H...ProgramMOVR0, ... Read More
In this section, we will see some bit manipulation operation using 8051. The 8051 supports some operations on different bits of an 8-bit number. The operations are like complementing, setting to 1, moving, ANDing, ORing etc.In this example, we are taking a number AEH from location 10H, then after performing following bit related operations on that data, we are just storing the result at location 30H.The bit related operations that will be performed on that data, are as follows −Complement bit b2Move b5to b4OR b0and complement of b1 and store to C (b7)Set b6Reset bit b3Input is AEHBitPositionb7b6b5b4b3b2b1b0Value10101110OutputBitPositionb7b6b5b4b3b2b1b0Value01110010The output will be ... Read More
To format date, let us see the DateFormat.SHORT as well as DateFormat.LONG constants. Both of them displays different patterns.Here, we are formatting dates with getDateTimeInstance() method. Use the method to get a date and time format.For DateFormat.SHORT constant −DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); System.out.println(dateFormat.format(calendar.getTime()));For DateFormat.LONG constant −dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); System.out.println(dateFormat.format(calendar.getTime()));The following is an example −Example Live Demoimport java.text.DateFormat; import java.util.Calendar; public class Demo { public static void main(String s[]) { Calendar calendar = Calendar.getInstance(); // for SHORT date-time DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); System.out.println(dateFormat.format(calendar.getTime())); ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP