ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to round off the value of the floating-point number

Here, we are going to learn how to round off the value of the floating-point number in VB.Net?
Submitted by Nidhi, on December 02, 2020

Here, we will round off a decimal floating-point value using the Round() method of Math class, which will return value after rounding off the floating-point value.

Program/Source Code:

The source code to round off the value of the floating-point number is given below. The given program is compiled and executed successfully.

'VB.Net program to round off a 
'floating-point value.

Module Module1

    Sub Main()
        Dim num1 As Decimal = 3.26
        Dim num2 As Decimal = 0

        num2 = Math.Round(num1)

        Console.WriteLine("num1: {0}", num1)
        Console.WriteLine("num2: {0}", num2)

    End Sub

End Module

Output:

num1: 3.26
num2: 3
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains the Main() method. In the Main() method we created two local variables num1, num2 that are initialized with 3.26 and 0 respectively.

num2 = Math.Round(num1)

Console.WriteLine("num1: {0}", num1)
Console.WriteLine("num2: {0}", num2)

Here, we used Round() method of Math class. The Round() method will round off the value of variable num1 and assigned to the variable num2.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.