Finding the absolute value in Java

In mathematics, the absolute value of a number is its non-negative value, i.e. the absolute value of?-2?is?2.

Absolute value in Java

In order to retrieve the absolute value in Java, we use the?abs()?function.

Syntax

The general syntax of the?abs()?function is:

No alt text provided for this image

Parameters

The function takes as input the argument whose absolute value is to be determined.

Return value

The function returns the absolute value of the argument.

Example

Let’s take a look at how we can find the absolute value using the?abs()?function!

No alt text provided for this image





要查看或添加评论,请登录

Omar Ismail的更多文章

社区洞察

其他会员也浏览了