Solved

VB.Net Stop ineger rounding

Posted on 2011-03-02
7
415 Views
Last Modified: 2012-05-11
Hey,

How do I stop an integer from rounding?
I have numbers set out as #.##, but it always rounds to just 1 number.

How do I stop this?

Thanks!
0
Comment
Question by:Letsgetcoding
[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
7 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 35017569
can u post the whole code?

i tried this and it didn;t round:

Dim s As String
        s = Format(0.15162342, "#.##") -->0.15

        s = Format(0.85162342, "#.##") --> 0.85
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 35017576
which value did u tried and was rounded to 1?
0
 

Author Comment

by:Letsgetcoding
ID: 35017604
Private HomepageFeature As Integer = 39
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35017977
You can't stop and Integer from rounding. An integer by definition is a whole (i.e. non-decimal) number. You need to change data type to a floating-point type if you want decimals.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 35018013
39 is an integer type so how exactly it was rounded to 1?!?!?
i don't understand where the issue comes from, can u explain with code?
0
 
LVL 3

Expert Comment

by:MTroutwine
ID: 35018262
You can take look at this article: http://vbnotebookfor.net/2007/07/31/what-you-should-know-about-rounding-in-vbnet/


However, I have to agree with the other comments.  If you are using an Integer data type you will not have any floating point value.  You will need to choose a data type that supports floating points such as Decimal, Float, Double. etc.
0
 

Author Comment

by:Letsgetcoding
ID: 35018942
Have decided to go with using a string. I misunderstood what an integer was.

Sedgwick, the part of code I was referring to was = 1. I copied the =39 by mistake. Sorry for the confusion.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

626 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