VB.Net
7 posts
• Page 1 of 1
VB.Net
Well I am back after a little time away from this board...and i have come back to ask another question.
Does anyone know how to convert a number such as 9.099999000999999 to just 9.09 in VB.NET. Any ideas? I am completely lost
You are going to want to look at topics with regard to "setting precision" You can set the precision to whatever you desire. Wish I could help you directly, but as you remember... I have never used VB.
-Weaver
Public Keys
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
- Weaver
- PROfessional Member
- Posts: 1967
- Joined: Wed Jun 19, 2002 12:05 am
- Location: /home/weaver/
easiest would probably be this ...
- Code: Select all
Dim s As String = "9.0999990009999987"
Dim x As Double = Convert.ToDouble(s.Substring(0, 4))
MessageBox.Show(x) '/// this will return 9.09
- dynamic_scripter
- Posts: 5
- Joined: Wed Mar 03, 2004 10:59 pm
- Location: UK
- Code: Select all
math.round(9.0999990009999987,2)
or
cdec(left("9.0999990009999987",4))
It returns (9.10), the second(9.09) (I think, check the syntax, might have to flip the numbers.
If you need anything else, try msdn.com
- Smartcat99S
- Posts: 2
- Joined: Sat Jul 12, 2003 12:40 am
- Location: Omaha, NE, USA
- Code: Select all
Math.Round(9.0999990009999987, 2)
- Code: Select all
CSng(Left(CStr(9.0999990009999987), 4))
7 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 2 guests