Karthikeya Boyini has Published 2383 Articles

Math Operations on BigInteger in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

2K+ Views

Let us apply the following operations on BigInteger using the in-built methods in Java.Addition: add() method Subtraction: subtract() method Multiplication: multiply() method Division: divide() methodLet us create three BigInteger objects.BigInteger one = new BigInteger("98765432123456789"); BigInteger two = new BigInteger("94353687526754387"); BigInteger three = new BigInteger("96489687526737667");Apply mathematical operations on them.one = one.add(two); ... Read More

ftp_rename() function in PHP

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

219 Views

The ftp_rename() function renames a file or directory on the FTP server.Syntaxftp_rename(conn, oldname, newname);Parametersconn − The FTP connectionold_name − The file or directory to rename.new_name − The new name of the file or directoryReturnThe ftp_rename() function returns TRUE on success or FALSE on failure.ExampleThe following is an example −Read More

BigInteger.isProbablePrime() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

155 Views

TheBigInteger.isProbablePrime(int certainty) returns true if this BigInteger is probably prime, false if it's definitely composite. If certainty is ≤ 0, true is returned.Here, the “certainty” parameter is a measure of the uncertainty that the caller is willing to tolerate: if the call returns true the probability that this BigInteger is ... Read More

ftp_set_option() function in PHP

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

64 Views

The ftp_set_option() function sets runtime options for the FTP connection.Syntaxftp_set_option(conn, option, value);Parametersconn − The FTP connectionoption − The runtime option to set. The following are the possible values:- FTP_TIMEOUT_SEC- FTP_AUTOSEEKvalue − The value of the option parameter set aboveReturnThe ftp_set_option() function returns TRUE if the option could be set, or ... Read More

Create BigDecimal Values via a long in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

128 Views

Let us see how we can create BigDecimal values via a long. Here, we have set long values as a parameter to the BigDecimal constructor.BigDecimal val1 = BigDecimal.valueOf(289L); BigDecimal val2 = BigDecimal.valueOf(299L);We can also perform mathematical operations on it −val2 = val2.subtract(val1);The following is an example −Example Live Demoimport java.math.BigDecimal; public ... Read More

Multiply one BigDecimal to another BigDecimal in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

1K+ Views

Use the multiply() method to multiply one BigDecimal to another in Java. This method returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()).The following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws ... Read More

ftp_size() function in PHP

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

43 Views

The ftp_size() function is used to get the size of a particular file on the FTP server.Syntaxftp_size(conn, myfile)Parametersconn − The FTP connectionmyfile − The server fileReturnThe ftp_size() function returns the size of the particular file in bytes on success.ExampleThe following is an example to get the size of file “new.txt” ... Read More

Display AM/PM time marker with SimpleDateFormat(“a”) in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

768 Views

You can display AM/PM time marker easily in Java using SimpleDateFormat(“a”).Firstly, to work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“a”) to display AM/PM marker −Format f = new SimpleDateFormat(”a”);Now, get the marker in a string −String strMarker = f.format(new Date());The following is ... Read More

SimpleDateFormat('zzzz') in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

603 Views

TimeZone can be formatted in z, Z or zzzz formats.The following is an example that displays how to implement SimpleDateFormat('zzzz') −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { ... Read More

Convert Long to numeric primitive data types in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

497 Views

Let’s say we have Long object here.Long myObj = new Long("9879");Now, if we want to convert this Long to short primitive data type. For that, use the in-built shortValue() method −// converting to short primitive types short shortObj = myObj.shortValue(); System.out.println(shortObj);In the same way convert Long to another numeric primitive ... Read More

Advertisements