How-to articles, tricks, and solutions about MATH

Basic Java Float and Integer multiplication casting

To perform a multiplication between a float and an integer in Java, you can simply use the * operator as you would with any other numeric data types. The result of the multiplication will be a float, even if one of the operands is an integer.

How can I check for NaN values?

You can use the isnan() function provided by the math module to check if a value is NaN.

How to Calculate Text Width with JavaScript

Read this JavaScript tutorial and learn about the best method of calculating the text width. Read about the advantages of the method over other methods.

How to Convert a Float Number to Whole Number in JavaScript

In this tutorial, you will read and learn detailed information about the methods used for converting a float number to a whole number with lots of examples.

How to evaluate a math expression given in string form?

There are a few different ways to evaluate a math expression given in string form:

How to Find the Min/Max Elements in an Array in JavaScript

Read this JavaScript tutorial and learn about the methods used to find the minimum and maximum number of elements in an array. Find the fastest solution.

How to Format Number with Two Decimals

In this JavaScript tutorial, you will find information about the formatting number to display with two decimals. Also, read about solving rounding issues.

How to Generate a Random Number Between Two Numbers in JavaScript

It is frequently necessary to generate a random number between two numbers while working with JavaScript. This snippet will help you to do it efficiently.

Math.random() explanation

Math.random() is a method in the java.lang.Math class that returns a random double value between 0.0 (inclusive) and 1.0 (exclusive).