?
Solved

Round a string to two digits

Posted on 2016-11-16
12
Medium Priority
?
37 Views
Last Modified: 2017-01-24
Hello,

How can I round a number to 2 digits

Cheers
0
Comment
Question by:RIAS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 29

Expert Comment

by:Pawan Kumar
ID: 41889515
Sample example pls?
0
 

Author Comment

by:RIAS
ID: 41889517
500.999
400.789
0
 
LVL 29

Expert Comment

by:Pawan Kumar
ID: 41889519
Output should be below correct ?

501.00
400.80
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:RIAS
ID: 41889522
400.789 to 400.79
0
 
LVL 29

Expert Comment

by:Pawan Kumar
ID: 41889523
Try

Dim a As Decimal
        a = 400.789

        Dim b As Decimal
        b = Math.Round(a, 2)

        Console.WriteLine(b)

Open in new window

0
 

Author Comment

by:RIAS
ID: 41889527
maths.round is giving sqiggly red line
0
 
LVL 29

Expert Comment

by:Pawan Kumar
ID: 41889528
Math.Round
0
 

Author Comment

by:RIAS
ID: 41889530
yes, math.round red squggly
0
 

Author Comment

by:RIAS
ID: 41889532
Severity      Code      Description      Project      File      Line      Suppression State
Error      BC30519      Overload resolution failed because no accessible 'Round' can be called without a narrowing conversion:
0
 
LVL 29

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 1000 total points
ID: 41889533
Math.Round

put same case I have given.. M and R should be capital , others small..
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 1000 total points
ID: 41889543
Wierd, I made a comment in your last question and it was rejected because it rounded to 2 digits rather than truncated.
d.ToString("0.00")
0
 

Author Comment

by:RIAS
ID: 41889571
Andy,

Sorry just overlooked it.

Cheers!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question