Solved

Round a string to two digits

Posted on 2016-11-16
12
34 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 28

Expert Comment

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

Author Comment

by:RIAS
ID: 41889517
500.999
400.789
0
 
LVL 28

Expert Comment

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

501.00
400.80
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

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

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 28

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 28

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 250 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 250 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

Technology Partners: 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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