Count Set Bits in a Floating Point Number in C

Samual Sam
Updated on 30-Jul-2019 22:30:26

559 Views

In this problem, one floating point value is given. We have to find number of set bits in the binary representation of it.For example, if a floating point number is 0.15625, so there are six set bits. A typical C compiler used single precision floating point representation. So it will be look like this.To convert into its bit values, we have to take the number into one pointer variable, then typecast the pointer to char* type data. Then process each byte one by one. Then we can count set bits of each char.Example#include int char_set_bit_count(char number) {    unsigned ... Read More

Java SQL Timestamp valueOf Method with Example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

2K+ Views

The valueOf() method of the java.sql.Timestamp class accepts a String value representing a time stamp in JDBC escape format and converts the given String value into Timestamp object.Timestamp timeStamp = Time.valueOf("timeStamp_string");ExampleLet us create a table with name dispatches_data in MySQL database using CREATE statement as shown below:CREATE TABLE dispatches_data(    ProductName VARCHAR(255),    CustomerName VARCHAR(255),    DispatchTimeStamp timestamp,    Price INT,    Location VARCHAR(255));Now, we will insert 5 records in dispatches_data table using INSERT statements:insert into dispatches_data values('Key-Board', 'Raja', TIMESTAMP('2019-05-04', '15:02:45'), 7000, 'Hyderabad'); insert into dispatches_data values('Earphones', 'Roja', TIMESTAMP('2019-06-26', '14:13:12'), 2000, 'Vishakhapatnam'); insert into dispatches_data values('Mouse', 'Puja', TIMESTAMP('2019-12-07', '07:50:37'), 3000, 'Vijayawada'); insert into ... Read More

Updating Boolean Value in MySQL

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

639 Views

To update boolean value, you can use SET. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, isMarried boolean    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(isMarried) values(false); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(isMarried) values(true); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(isMarried) values(true); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(isMarried) values(false); Query OK, 1 row affected (0.13 sec)Display all records ... Read More

Request Location Permission at Runtime on iOS

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

1K+ Views

To request location Permission we will be using Apple’s CLLocationManager class. You use instances of this class to configure, start, and stop the Core Location services.You can read more about CLLocationManager class here. https://developer.apple.com/documentation/corelocation/cllocationmanageriOS apps can support one of two levels of location access.While using the app − The app can access the device’s location when the app is in use. This is also known as “when-in-use authorization.”Always − The app can access the device’s location either when app is in use or in the background.Here we will be using when-in-use authorization: Request authorization to use location services only when your ... Read More

Align Views at the Bottom of the Screen in Android

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

6K+ Views

This example demonstrate about How to align views at the bottom of the screen 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.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add the following code to androidManifest.xml                       ... Read More

Select and Display Specific Field from MongoDB Document

Anvi Jain
Updated on 30-Jul-2019 22:30:26

2K+ Views

Let us first create a collection with documents −> db.querySelectDemo.insertOne({UserId:100, UserName:"Chris", UserAge:25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90eb478f00858fb12e90e") } > db.querySelectDemo.insertOne({UserId:101, UserName:"Robert", UserAge:26}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90ec578f00858fb12e90f") } > db.querySelectDemo.insertOne({UserId:103, UserName:"David", UserAge:27}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90ed478f00858fb12e910") }Following is the query to display all documents from a collection with the help of find() method −> db.querySelectDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ce90eb478f00858fb12e90e"),    "UserId" : 100,    "UserName" : "Chris",    "UserAge" : 25 } {    "_id" : ObjectId("5ce90ec578f00858fb12e90f"),    "UserId" : 101, ... Read More

Transient Variables in Java Explained

Venkata Sai
Updated on 30-Jul-2019 22:30:26

418 Views

In Java, serialization is a concept using which we can write the state of an object into a byte stream so that we can transfer it over the network (using technologies like JPA and RMI).While serializing an object of a class, if you want JVM to neglect a particular instance variable you need can declare it transient.public transient int limit = 55; // will not persist public int b; // will persistIn the following java program, the class Student has two instance variables name and age where, age is declared transient. In another class named EampleSerialize we are trying to ... Read More

Why MySQL Evaluates True or True AND False to True

Sharon Christine
Updated on 30-Jul-2019 22:30:26

258 Views

MySQL evaluates “TRUE or TRUE and FALSE” to true because AND has the highest priority than OR i.e. AND is evaluated before OR.The MySQL evaluates the above statement like this. The AND operator gets evaluated first −(TRUE or (TRUE AND FALSE))The statement (TRUE AND FALSE) gives the result FALSE. Then the second statement evaluates like this −(TRUE or FALSE)The above statement gives the result TRUE.Let us implement one by one −mysql> select (TRUE AND FALSE); +------------------+ | (TRUE AND FALSE) | +------------------+ | 0 | ... Read More

HTML DOM Input Week Autofocus Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

135 Views

The Input Week autofocus property sets/returns whether Input Week is focused upon initial page load.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputWeekObject.autofocusSetting autofocus to booleanValueinputWeekObject.autofocus = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailsTrueIt defines that input will be autofocused on page load.FalseIt is the default value and input is not autofocused.ExampleLet us see an example for Input Week autofocus property − Live Demo Input Week autofocus    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;     ... Read More

Add Titled Border to Panel in Swing

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

295 Views

To set Titled Border to Panel, let us first create a Panel for our Java Swing Application:JPanel panel = new Jpanel(new BorderLayout());Now, set the titled border:panel.setBorder(new TitledBorder("Displaying Titled Border"));The following is an example to add Titled Border to Panel in Swing:Exampleimport java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.border.TitledBorder; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       panel.setBorder(new TitledBorder("Displaying Titled Border"));       panel.add(new JButton("Demo Button"), BorderLayout.SOUTH);       JOptionPane.showMessageDialog(null, panel);    } }OutputRead More

Advertisements