473,587 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

format

Tom
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #1
3 928
"Tom" <To*@yahoo.comw rote in message
news:Ok******** ******@TK2MSFTN GP06.phx.gbl...
>I have this

131.988

I want
132

how can I accomplish this?

double MyDouble = 131.988;
string MyFormattedDoub le = MyDouble.ToStri ng("0");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Feb 6 '08 #2
Your question should be more to the point. Usually a piece of code helps us
give you better answers.

But here it goes

dim value decimal = 131.987
label1.text = format(value, "#0")

will give you 132
--
aaa
"Tom" wrote:
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #3
If you are looking to just round, you can convert the number to an integer as
well.

VB.NET
Dim decimalNumber As Decimal = 131.988
Dim intNumber As Integer = decimalNumber ' intNumber will be 132
or you can show you are converting it (use one of these methods depending on
how big your integer can get)
Dim intNumber As Integer = Convert.ToInt16 (doubleNumber)
Dim intNumber As Integer = Convert.ToInt32 (doubleNumber)
Dim intNumber As Integer = Convert.ToInt64 (doubleNumber)

or if your starting number is a double:

Dim doubleNumber As Double = 131.988
Dim intNumber As Integer = doubleNumber
C#
double doubleNumber = 131.988;
int integerNumber = Convert.ToInt16 (doubleNumber);

or depending on how big your integer will get you can also use:
int integerNumber = Convert.ToInt32 (doubleNumber);
int integerNumber = Convert.ToInt64 (doubleNumber);

Is your starting number of 131.988 a string?
You can also use (VB.NET):
Dim doubleString As String = "131.988"
Dim intNumberFromSt ring As Integer = doubleString

"Tom" wrote:
I have this

131.988

I want
132

how can I accomplish this?
Feb 6 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2155
by: Lowell Kirsh | last post by:
In Peter Norvig's Infrequently Answered Questions he explains that the following 2 fnctions look almost identical but are not the same: def printf(format, *args): print format % args, def printf(format, *args): print str(format) % args, The only difference is that in the second one, str(format) replaces format. If args are not given and...
15
42995
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our...
3
19222
by: stevek | last post by:
How do I format an integer. Add commas. 1234565 1,234,565 TIA
6
31139
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date format exception (SQLSTATE=22007). The same queries worked fine on all the other workstations. The date format we want to use is "dd/mm/yyyy".After...
3
12117
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
11
5928
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <= 4 */ };
7
6488
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me where I can look up explaination on the String.Format, the format string part like "("{0:.#0}". What's the trailing 0 and what is that "0:" means? ...
4
1627
by: David Morris | last post by:
Hi Could somebody please explain what the following line of code means String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1 It's actually the first argument that I don't understand. What is the purpose of "{0}\{1}.{2:00}"? I've been using VB .NET for a year now, and have never come across anything like this Best Regards David Morris
13
3290
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way to configure server, sql server or program so it always deals with date as mm/dd/yyyy format. Thanks in advance. Roy
3
1946
by: Carl Trachte | last post by:
Hello. Python 3.0.a1 has been released. I'm trying to get the hang of the new string formatting in the form: '5.66' There are more options in PEP 3101 (fill, alignment, etc.), but I'm having trouble implementing them. The doc has not yet been written. I haven't consulted the source code yet.
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.