Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

scala
math
decrease
communitycreator

What is decrementExact(x: Int) in Scala?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

decrementExact(x: Int) is a function in the Math package of Scala that decreases the argument by 1 and returns it.

Syntax


def decrementExact(x: Int): Int

Parameters

The function takes in one parameter, x, of type int.

Return value

The decrementExact() function returns the value of x decreased by 1, i.e., x1x-1.


The function throws ArithmeticException if int is overflowed by the return value.

Code

object MainObject {
def main(args: Array[String]): Unit = {
var x : Int = 130;
println("Math.decrementExact(x) = " + Math.decrementExact(x));
}
}

RELATED TAGS

scala
math
decrease
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring