Trusted answers to developer questions

Arslan Bajwa

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.

C# has a built-in Math class that provides useful mathematical functions and operations. The class has the ** Abs() function**, which is used to compute the

```
Abs (type param);
```

where:

`param`

is a number greater than or equal to`MinValue`

and less than or equal to`MaxValue`

.

Returns a value such that:

- 0 <= value <=
`MaxValue`

`MinValue`

and`MaxValue`

are equal to the minimum and maximum value of integer that can be stored in that specific type.

This function returns the absolute value of a decimal number.

```
public static decimal Abs (decimal param);
```

This function returns the absolute value of a double-precision floating-point number.

```
public static double Abs (double param);
```

This function returns the absolute value of a 16-bit signed number.

```
public static short Abs (short value);
```

This function returns the absolute value of a 32-bit signed number.

```
public static int Abs (int param);
```

This function returns the absolute value of a 64-bit signed number.

```
public static long Abs (long param);
```

This function returns the absolute value of an 8-bit signed number.

```
public static sbyte Abs (sbyte param);
```

This function returns the absolute value of a single-precision floating-point number.

` public static float Abs (float param);`

using System;class HelloWorld{static void Main(){System.Console.WriteLine(Math.Abs(-2));System.Console.WriteLine(Math.Abs(-58.2M));System.Console.WriteLine(Math.Abs(-58.2));System.Console.WriteLine(Math.Abs(0.0));}}

RELATED TAGS

c#

math

communitycreator

CONTRIBUTOR

Arslan Bajwa

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

Related Courses