C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Tip: The value returned from Math.Abs is of the same type as the value you pass to it.
So: If you pass a Double as the argument to Math.Abs, it also returns a Double.
VB.NET program that computes absolute values
Module Module1
Sub Main()
' Absolute values of integers.
Dim value1 As Integer = -1000
Dim value2 As Integer = 20
Dim abs1 As Integer = Math.Abs(value1)
Dim abs2 As Integer = Math.Abs(value2)
Console.WriteLine(value1)
Console.WriteLine(abs1)
Console.WriteLine(value2)
Console.WriteLine(abs2)
' Absolute values of doubles.
Dim value3 As Double = -100.123
Dim value4 As Double = 20.2
Dim abs3 As Double = Math.Abs(value3)
Dim abs4 As Double = Math.Abs(value4)
Console.WriteLine(value3)
Console.WriteLine(abs3)
Console.WriteLine(value4)
Console.WriteLine(abs4)
End Sub
End Module
Output
-1000
1000
20
20
-100.123
100.123
20.2
20.2