CORE API / CATATAN</>↗Core API17 Mar 2010
We can calculate logarithm using the Math.log10() and the Math.log() static method call. package org.kodejava.math; public class LogarithmExample { public static void main(String[] args) { double number1 = 1000.0d; // Get common logarithm double log10 = Math.log10(number1); System.out.println("Common logarithm of " + number1 + " = " + log10); // Get natural logarithm double loge […]
CORE API / CATATAN</>↗Core API16 Mar 2010
The example below show you some methods of the Math class that can be used to round the value of a number. These methods are Math.ceil(), Math.floor() and Math.round(). package org.kodejava.math; public class GetRoundedValueExample { public static void main(String[] args) { Double number = 1.5D; // Get the smallest value that is greater than or […]
CORE API / CATATAN</>↗Core API12 Mar 2010
To calculate the cube root and the square root of a double value we can use the Math.cbrt(double a) and Math.sqrt(double a) static method call. package org.kodejava.math; public class CubeSquareRootExample { public static void main(String[] args) { double cube = 125.0d; double square = 100.0d; // Get the cube root of double value double cubeRoot […]
CORE API / CATATAN</>↗Core API09 Mar 2010
The example shown below tells you how to reread the contents of a buffer. To reread the data from a buffer we can use the buffer’s rewind() method. This method set the position back to 0 while the limit is unchanged, it still holds the value of how many data can be read from the […]
CORE API / CATATAN</>↗Core API09 Mar 2010
This example demonstrates how to use the trigonometric methods of the java.lang.Math class. You can see the use of method such as Math.sin(), Math.cos(), Math.tan(), etc. package org.kodejava.math; public class TrigonometricExample { public static void main(String[] args) { double radians = 1.0d; double sine = Math.sin(radians); double cosine = Math.cos(radians); double tan = Math.tan(radians); double […]
CORE API / CATATAN</>↗Core API06 Mar 2010
The example below show you how to convert an angle measured in radians into degrees and vice versa. We can use the Math.toDegrees() and Math.toRadians() method call to do the conversion. package org.kodejava.math; public class RadiansDegreeConversionExample { public static void main(String[] args) { double radians = 1.0d; double degrees = 45d; // Converts an angle […]