VB.Net Stop ineger rounding

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!
LetsgetcodingAsked:
Who is Participating?
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
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
 
Meir RivkinFull stack Software EngineerCommented:
which value did u tried and was rounded to 1?
0
 
LetsgetcodingAuthor Commented:
Private HomepageFeature As Integer = 39
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Carl TawnSystems and Integration DeveloperCommented:
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
 
Meir RivkinFull stack Software EngineerCommented:
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
 
MTroutwineCommented:
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
 
LetsgetcodingAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.