Computer Science, asked by vishalem2006, 5 months ago

4. Explain .ceil() and .cbrt() functions with example​

Answers

Answered by BrainlyProgrammer
5

Question:-

  • Explain Math.ceil() and Math.cbrt() functions with example

Answer:-

•Math.ceil():-

  1. Rounds up the value upto next higher integer
  2. It always returns the value in double data type
  3. Example:- Math.ceil(2.5) Here in this example, the value gets rounded up to next higher integer i.e. 3 but the output will be 3.0 because it returns in double data type value
  4. Let's have another example to understand the concept of ceil().... Math.ceil(4.3) Here in this example, the value gets rounded up to next higher integer i.e. 5 but the output will be 5.0 because it returns in double data type.
  5. In case of negative numbers, Math.ceil(-4.3) here it will return -4.0 as -4.0 is higher than -4.3.

 \rule{55mm}{1pt}

•Math.cbrt():-

  1. Finds the cube root of a number
  2. Like Math.ceil(), Math.cbrt() also returns double data type value
  3. A very simple example for this is Math.cbrt(8) here it will return 2 in double data type value i.e. the output will be 2.0
  4. Another example is Math.cbrt(-64) Here cube root of 64 is 4, but 64 is negative so the correct output will be -4 in double data type value i.e. -4.0

 \rule{55mm}{1pt}

More about Math Functions:-

  1. Math.max() is used to find the maximum value between 2 numbers. SYNTAX:- Math.max(a,b);
  2. Math.min() returns the minimum value between two numbers. SYNTAX:- Math.min(x,y);
  3. Math.abs() returns absolute value of the given number. SYNTAX:- Math.abs(a);
  4. Math.ceil() returns rounded value upto nearest higher integer. SYNTAX:- Math.ceil(x);
  5. Math.floor() returns rounded value upto nearest lower integer. SYNTAX;- Math.floor(x);
  6. Math.round() returns the rounded value of the number upto nearest integer. SYNTAX:- Math.round(x);
  7. Math.cbrt() returns cube root of a number. SYNTAX:- Math.cbrt(x);
  8. Math.sqrt() returns square root of a positive real number. SYNTAX:- Math.sqrt(x);
Similar questions