Compare BigDecimal movePointRight and scaleByPowerOfTen in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

283 Views

The java.math.BigDecimal.movePointRight(int n) returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right. If n is non-negative, the call merely subtracts n from the scale.The java.math.BigDecimal.scaleByPowerOfTen(int n) returns a BigDecimal whose numerical value is equal to (this * 10n). The scale of the result is (this.scale() - n).The following is an example displaying the usage of both −Example Live Demoimport java.math.BigDecimal; public class Demo {    public static void main(String... args) {       long base = 3676;       int scale = 5;       BigDecimal d = ... Read More

Add Separator to Numbers Using MySQL Views

Chandu yadav
Updated on 30-Jul-2019 22:30:25

172 Views

Let us first create a table −mysql> create table DemoTable (    StudentId int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(343898456); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(222333444); Query OK, 1 row affected (0.22 sec)Following is the query to display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-----------+ | StudentId | +-----------+ | 343898456 | | 222333444 | +-----------+ 2 rows in set (0.00 sec)Here is the query to create view ... Read More

Generation of OBJ File Using a Cross Assembler

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

395 Views

Generation of .OBJ file by using a cross-assembler:The file assembly language program file, e.g. MULT.ASM which is created by using an editor is simply a text file. We cannot execute this file directly. At first we have to assemble the file, and then we have to link it. The step of assembly the translation of the program of assembly language to machine code requires the generation of a .OBJ file.We have used some examples in the text of ‘2500 A.D i.e. the 8085 cross-assembler of version 4.01.In the prompt mode the translation is:We type ‘X8085’ just for performing the translation ... Read More

Status Check of Data Transfer in 8085

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

489 Views

Status check data transfer process is a much more complex process than simple data transfer. We use this method is used when there is lack of accurate knowledge of the Input Output device consisting of the timing characteristics. Status information is received by the processor regarding the readiness of the Input Output device for performing the data transfer. Generally, the processor is involved in the checking of the loop for the device to get ready. The device releases from the loop when the device is ready for use for the execution of the IN or OUT instruction which depends on ... Read More

Read Image File in External Storage with Runtime Permission in Android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

This example demonstrates How to read an image file in external storage with runtime permission in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken image view and button. When user click on button, it will take data from external storage and append the data to Image view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.pm.PackageManager; ... Read More

Check If a Stored Procedure Exists in MySQL

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

872 Views

Let us first create a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE ExtenddatesWithMonthdemo(IN date1 datetime, IN NumberOfMonth int )    -> BEGIN    -> SELECT DATE_ADD(date1, INTERVAL NumberOfMonth MONTH) AS ExtendDate;    -> END;    -> // Query OK, 0 rows affected (0.20 sec) mysql> DELIMITER ;Now you check whether the stored procedure exists with the help SHOW CREATE command.The query is as follows −mysql> SHOW CREATE PROCEDURE ExtenddatesWithMonthdemo; The following is the output displaying the details of the stored procedure we created above: +--------------------------+--------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | Procedure                | sql_mode ... Read More

Prepared Statements in JDBC: Why They Are Faster

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

600 Views

While executing statements using Statement object, especially insert statements, each time a query is executed the whole statement is compiled and executed again and again where, the only difference among these statements is the values of the statements.Whereas, prepared statement is a precompiled statement i.e. the query is compiled and stored in the database, using place holders (?) instead of values and values to these place holders are supplied later.Thus, avoiding unnecessary compilation and execution of the statement again and again.ExampleSuppose, we have a table named Dataset in the database with the columns mobile_brand and unit_sale, if we want to ... Read More

Use indexOf in Android TextView

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

530 Views

This example demonstrate about How to use indexOf () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             In the above code, we have taken name as Edit text, when user click on button it will take data and returns index of “sai”.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More

Period withDays Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

206 Views

An immutable copy of a Period with the number of days as required is done using the method withDays() in the Period class in Java. This method requires a single parameter i.e. the number of days in the Period and it returns the Period with the number of days as required.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

LocalTime with Second Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

74 Views

An immutable copy of a LocalTime with the seconds altered as required is done using the method withSecond() in the LocalTime class in Java. This method requires a single parameter i.e. the second that is to be set in the LocalTime and it returns the LocalTime with the second altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt1 = LocalTime.parse("23:15:30");       System.out.println("The LocalTime is: " + lt1);       LocalTime lt2 = lt1.withSecond(45);       ... Read More

Advertisements