C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
And: With negative and positive numbers, this is not changed. The ceiling of -1.23 is -1.
VB.NET program that computes ceiling, uses Math.Ceiling
Module Module1
Sub Main()
' Ceiling returns the next highest integer if a fraction part exists.
Dim result As Double = Math.Ceiling(1.23)
Console.WriteLine("CEILING 1.23: " + result.ToString)
Dim result2 As Double = Math.Ceiling(-1.23)
Console.WriteLine("CEILING -1.23: " + result2.ToString)
Dim result3 As Double = Math.Ceiling(1)
Console.WriteLine("CEILING 1: " + result3.ToString)
End Sub
End Module
Output
CEILING 1.23: 2
CEILING -1.23: -1
CEILING 1: 1
VB.NET program that computes floor, uses Math.Floor
Module Module1
Sub Main()
' Floor changes a number to the lower integer if a fraction part is present.
Dim floor As Double = Math.Floor(1.99)
Console.WriteLine("FLOOR 1.99: " + floor.ToString)
Dim floor2 As Double = Math.Floor(-1.99)
Console.WriteLine("FLOOR -1.99: " + floor2.ToString)
End Sub
End Module
Output
FLOOR 1.99: 1
FLOOR -1.99: -2