Math Flashcards

1
Q

double/int/long/float abs(double a)

A
  • Returns the absolute value of a double/int/long/float value.
  • Also works with int/long/float arguments, returning int/long/float values respectively
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

double/int/long/float max(arg, arg)

A
  • Returns the bigger of two double/int/long/float values.
  • Works with double/int/long/float arguments, returning double/int/long/float values respectively
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

double/int/long/float min(arg, arg)

A
  • Returns the smaller of two double/int/long/float values.
  • Also works with int/long/float arguments, returning int/long/float values respectively
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

double ceil(double a)

A
  • Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

double floor(double a)

A
  • Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Math.rint() vs Math.round()

A
  • double rint(double a): Returns the double value that is closest in value to the argument and is equal to a mathematical integer.
  • long round(double a): Returns the closest long to the argument, with ties rounding to positive infinity.
  • They differ in the way they handle rounding of integers which are on a boundary, like 4.5.
  • For example for : double val = 4.5;
    • Math.rint(val) = 4.0
    • Math.round(val) = 5
    • As you can see Math.rint(4.5) actually rounds down, while Math.round(4.5) rounds up. That is the main difference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly