#### Round(0.5) returns 0.

```Hi,

Dim d as double
d= 0.5
Round(d) returns 0

d= 1.5
Round(d) returns 2

I need Round(0.5) = 1. Is it possible in .net?

--
Thanks & regards,

V.Vallikkannu

This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
sender by reply e-mail and destroy all copies of the original message.

Any unauthorized review, use, disclosure, dissemination, forwarding,
printing or copying of this email is strictly prohibited and may be
unlawful.

```
 0
Valli
3/27/2010 9:57:18 AM
dotnet.languages.vb 830 articles. 0 followers.

7 Replies
819 Views

Similar Articles

[PageSpeed] 20

```Am 27.03.2010 10:57, schrieb Valli:
> Hi,
>
> Dim d as double
> d= 0.5
>  Round(d) returns 0
>
> d= 1.5
>  Round(d) returns 2
>
> I need Round(0.5) = 1. Is it possible in .net?

I don't know which Round function you are using here, without a
qualifier. Try Math.Round:

d = Math.Round(d, MidpointRounding.AwayFromZero)

--
Armin
```
 0
Armin
3/27/2010 11:18:23 AM
```For what it`s worth ,,

The Round function goes to the nearest integer, and if there are two nearest
integers then it goes to the even one.  1.5 rounds to 2, 0.5 rounds to 0.

The behavior you noticed is not specific to .Net  , it is called  "Bankers
rounding" and it is the standard rounding method used in every programming
language
dating back to COBOL and maybe even further ( maybe Cor can tell us that
-)  )

The rounding that you want is mathmetical rounding as how you have learned
to round in basic scholar math courses
this rounding method is     midpointrounding  away from zero

http://blogs.msdn.com/ericlippert/archive/2003/09/26/bankers-rounding.aspx

HTH

Michel

"Armin Zingler" <az.nospam@freenet.de> schreef in bericht
news:%239U3l9ZzKHA.2016@TK2MSFTNGP02.phx.gbl...
> Am 27.03.2010 10:57, schrieb Valli:
>> Hi,
>>
>> Dim d as double
>> d= 0.5
>>  Round(d) returns 0
>>
>> d= 1.5
>>  Round(d) returns 2
>>
>> I need Round(0.5) = 1. Is it possible in .net?
>
> I don't know which Round function you are using here, without a
> qualifier. Try Math.Round:
>
>    d = Math.Round(d, MidpointRounding.AwayFromZero)
>
> --
> Armin

```
 0
Michel
3/27/2010 12:37:49 PM
```Michel,

Rounding was in the beginning not build in, you had to create your own
mathematical functions for that.

I  was not aware before Net about Bankers rounding, can be lack of my
knowledge but that is simply the truth

Cor

"Michel Posseth [MCP]" <msdn@posseth.com> wrote in message
news:4D0D91AE-235C-47D6-80F3-19B3788DE43B@microsoft.com...
>
> For what it`s worth ,,
>
> The Round function goes to the nearest integer, and if there are two
> nearest integers then it goes to the even one.  1.5 rounds to 2, 0.5
> rounds to 0.
>
> The behavior you noticed is not specific to .Net  , it is called  "Bankers
> rounding" and it is the standard rounding method used in every programming
> language
> dating back to COBOL and maybe even further ( maybe Cor can tell us
> that -)  )
>
> The rounding that you want is mathmetical rounding as how you have learned
> to round in basic scholar math courses
> this rounding method is     midpointrounding  away from zero
>
> http://blogs.msdn.com/ericlippert/archive/2003/09/26/bankers-rounding.aspx
>
>
> HTH
>
> Michel
>
>
> "Armin Zingler" <az.nospam@freenet.de> schreef in bericht
> news:%239U3l9ZzKHA.2016@TK2MSFTNGP02.phx.gbl...
>> Am 27.03.2010 10:57, schrieb Valli:
>>> Hi,
>>>
>>> Dim d as double
>>> d= 0.5
>>>  Round(d) returns 0
>>>
>>> d= 1.5
>>>  Round(d) returns 2
>>>
>>> I need Round(0.5) = 1. Is it possible in .net?
>>
>> I don't know which Round function you are using here, without a
>> qualifier. Try Math.Round:
>>
>>    d = Math.Round(d, MidpointRounding.AwayFromZero)
>>
>> --
>> Armin
>
```
 0
Cor
3/27/2010 8:57:21 PM
```On 2010-03-27, Cor Ligthert[MVP] <Notmyfirstname@planet.nl> wrote:
> Michel,
>
> Rounding was in the beginning not build in, you had to create your own
> mathematical functions for that.
>
> I  was not aware before Net about Bankers rounding, can be lack of my
> knowledge but that is simply the truth
>

VB has used bankers rounding by default for as long as I can remember.

--
Tom Shelton
```
 0
Tom
3/28/2010 7:13:12 AM
```Tom,

Explicitly you write in my idea that the Net System values and methods are
build around Visual Basic (in what I not doubt) and not around C#.

:-)

Cor

"Tom Shelton" <tom_shelton@comcastXXXXXXX.net> wrote in message
news:eQiahYkzKHA.4328@TK2MSFTNGP04.phx.gbl...
> On 2010-03-27, Cor Ligthert[MVP] <Notmyfirstname@planet.nl> wrote:
>> Michel,
>>
>> Rounding was in the beginning not build in, you had to create your own
>> mathematical functions for that.
>>
>> I  was not aware before Net about Bankers rounding, can be lack of my
>> knowledge but that is simply the truth
>>
>
> VB has used bankers rounding by default for as long as I can remember.
>
> --
> Tom Shelton

```
 0
Cor
3/28/2010 9:49:00 AM
```Cor Ligthert[MVP] wrote:
> Tom,
>
> Explicitly you write in my idea that the Net System values and methods
> are build around Visual Basic (in what I not doubt) and not around C#.
>
> And that from your pen
>
> :-)
>
> Cor
>

....and as usual you have a strange idea about what people write.

Just because one single concept that exists in the .NET framework also
exists in VB, doesn't mean that everything in the framework comes from VB.

>
> "Tom Shelton" <tom_shelton@comcastXXXXXXX.net> wrote in message
> news:eQiahYkzKHA.4328@TK2MSFTNGP04.phx.gbl...
>> On 2010-03-27, Cor Ligthert[MVP] <Notmyfirstname@planet.nl> wrote:
>>> Michel,
>>>
>>> Rounding was in the beginning not build in, you had to create your own
>>> mathematical functions for that.
>>>
>>> I  was not aware before Net about Bankers rounding, can be lack of my
>>> knowledge but that is simply the truth
>>>
>>
>> VB has used bankers rounding by default for as long as I can remember.
>>
>> --
>> Tom Shelton
>

--
_____
http://www.guffa.com
```
 0
ISO
3/30/2010 9:23:45 AM
```On Mar 30, 4:23=A0am, G=F6ran Andersson <gu...@guffa.com> wrote:
> Cor Ligthert[MVP] wrote:
> > Tom,
>
> > Explicitly you write in my idea that the Net System values and methods
> > are build around Visual Basic (in what I not doubt) and not around C#.
>
> > And that from your pen
>
> > :-)
>
> > Cor
>
> ...and as usual you have a strange idea about what people write.
>
> Just because one single concept that exists in the .NET framework also
> exists in VB, doesn't mean that everything in the framework comes from VB=
..
>
>
>
>
>
>
>
> > "Tom Shelton" <tom_shel...@comcastXXXXXXX.net> wrote in message
> >news:eQiahYkzKHA.4328@TK2MSFTNGP04.phx.gbl...
> >> On 2010-03-27, Cor Ligthert[MVP] <Notmyfirstn...@planet.nl> wrote:
> >>> Michel,
>
> >>> Rounding was in the beginning not build in, you had to create your ow=
n
> >>> mathematical functions for that.
>
> >>> I =A0was not aware before Net about Bankers rounding, can be lack of =
my
> >>> knowledge but that is simply the truth
>
> >> VB has used bankers rounding by default for as long as I can remember.
>
> >> --
> >> Tom Shelton
>
> --
> _____http://www.guffa.com- Hide quoted text -
>
> - Show quoted text -

if you are taking about a label or textbox for output it would be:

lbl.text =3D format (your calc or variable, "0.00")

if you want to round for calculation, who cares...  fix it on output!
```
 0
jdrott1
3/31/2010 8:29:15 PM

Similar Artilces:

rounding #9
is there a way to have a column round automatically instead of having to round onto another column? I don't want to add another column to just be able to round. -- denhar ------------------------------------------------------------------------ denhar's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24089 View this thread: http://www.excelforum.com/showthread.php?threadid=378356 If the column contains formulas, the formulas can incorporate the Round() function within themselves. For example, if the formula is: =A1*B1 it could be revised to: =ROUND(A1*...

Integration with MS CRM 3.0 by accessing directly the SQL dbs
What kind of implications could bring if our intranet applications retrieve, insert and update data by accessing directly the MS CRM dbs? What kind of alternative integration you could suggest except web services? Our intranet applications include a Java Web app and some other windows apps written in VB. try www.scribesoft.com "George" <George@discussions.microsoft.com> wrote in message news:8A6906A5-B6D4-45BC-9E0F-F42ACC9F6454@microsoft.com... > What kind of implications could bring if our intranet applications > retrieve, > insert and update data by accessin...

round() ?
Hello How can i round float to 2 digits after '.' ? Thanx Quick and Dirty: Multiply by 100, add 0.5 (to round up correctly). convert to long, then back to float, then divide by 100. This is limited to values that will fit within a long, and is not efficient. It is reliable. also: float val; val = val - fmod(val, .01); Or, the real thing: char *_fcvt( double value, int count, int *dec, int *sign ); Which is a char string, which you can then feed to atof() and get your rounded value back. Alas, beware errors in precision limits! Balboos user@domain.invalid wrote: >...

Rounding question
I'm using Excel 2007 but 'save as' 97-2003 as colleagues have different versions. All number formats are set to 2 decimal places. I'm finding that percentage calculations are rounding up to 2 decimal places but when the result in currency is subtracted from another figure the sum is rounded down. This gives results such as 6 - 3 = 4. I'm sure there must be a simple answer but I can't find it. Hoping someone here knows, as checking all simple calcuations is getting ridiculous ! Carrie "Carrie" <pantscarolyn.smith2@ntlworld.com> w...

Loss of code in button(s)
I did a repair on my .mdb and the code within my button was deleted. I also lost code within other buttons, the same .mdb when transferring my file from the hard drive (c:\) to a server drive. Why does this happen?I was also having problems with the code working correctly; I would get error messages stating that I was in design mode when I was not. I recreated the code in another .mdb and it worked fine. I also recreated the code in another form in the same .mdb and it was fine as well. Is there a corrupt object on the form that could be causing this problem ? Thank you. BelleCest My gu...

deleting a file in VC++ 6.0
Can someone show me how to delete a known file within a VC++ 6.0 MFC app. Thanks An MFC way to do it would be CFile::Remove() http://msdn2.microsoft.com/en-us/library/a9skzxhx(VS.80).aspx Tom "Ed" <eddie@hvc.rr.com> wrote in message news:gb%0i.2\$R97.0@trndny03... > Can someone show me how to delete a known file within a VC++ 6.0 MFC app. > Thanks > > The same way you delete it in a Win32 app, a console app, a VS2005 app, etc: ::DeleteFile if(!::DeleteFile(pathnamehere)) { /* failed */ DWORD err = ::GetLastError(); ...

RMS 2009 ~ 3.0 Say it ain't so!
Tell me it aint so...did they really do away with some, in my opinion very useful features? Rumor has it there is no more Buydown Pricing...Buydown Price/Buydown Quantity, and there is also no more Messages...can anyone confirm? Thank You, Vince -- Thank You Vince :) It is true some of the features have been removed, but I would have to check on the specific ones you listed. However, with this new release (named POS 2009, not RMS 2009), the SDK is better documented so the features not currently present can more than likely be accomplished with customizations. "Vince" wr...

What are the shortcut keys for "0.00"
How do I apply the general number format "0.00" to the selection using shortcut keys? Can't find it via the help feature. Thanks. Epinn Hi Eppin, There is the 'increase decimal' and 'decrease decimal' buttons on the formatting Toolbar. HTH Martin CTRL-1 is the shortcut for format cells, but you would still have to click the Number tab and click OK for 2 decimal places. General format does not only apply to numbers. Hope this helps. Pete Epinn wrote: > How do I apply the general number format "0.00" to the selection using > shortcut k...

Problem with rounding currency values
Hi, I am using the Sales Global Procedure SOP_Calculate_Trade_Discount_Split. This procedure returns the line trade discount. The line trade discount returned is rounded off. eg: if value is 6.76 then it returns 7.00. Is there some place where i can specify to turn off the rounding off? The output type is Currency. Any help is greatly appreciated. Thanks & Regards, Sup ...

CRM 4.0 More than one user queue was found for the given object
Hi, I upgraded CRM 3.0 to CRM 4.0 and when trying to assign an account to another user get this error: "More than one user queue was found for the given object". This is the error with deverrors turned on in web.config. In the event viewer, I get the following: Event Type: Warning Event Source: ASP.NET 2.0.50727.0 Event Category: Web Event Event ID: 1309 Date: 4/14/2008 Time: 9:03:57 PM User: N/A Computer: CRMSRVR Description: Event code: 3005 Event message: An unhandled exception has occurred. Event time: 4/14/2008 9:03:57 PM Event time (UTC): 4/15/2008 2:03:57 AM Eve...

Our company is currently looking after two domains on one Exchange 5.5 box.is it possible to have seperate global address lists for each domain ? because we dont want the users from one domain to be able to see the global address list of the other domain. (I new this question will follow) Use Address Book Views. George D wrote: > Our company is currently looking after two domains on one > Exchange 5.5 box.is it possible to have seperate global > address lists for each domain ? because we dont want the > users from one domain to be able to see the global > address list of ...

vc 6.0 control?
Hi all May i know how can i create a control like the vs.net toolbox windows? http://www.emailspoofer.net/images/vs.net.gif Or where i can buy a third party control like that? thanks from Peter (cmk128@hotmail.com) I use the library sold at: http://www.codejock.com. It has these features: http://www.codejock.com/products/propertygrid/ http://www.codejock.com/products/taskpanel/tour_first.asp That might do what you need. There are similar libraries at: http://www.bcgsoft.com Tom <cmk128@hotmail.com> wrote in message news:1183096679.088042.192560@a26g2000pre.googlegroups.com...

Rights propatagion in p-folders (mixed mode exchg 5.5 and 2003)
I'm having difficulties propagating public folder permissions. Public Folders are actually sitting on an exchange 5.5 server and i also have an exchange 2003 server. All our upgrades were put on hold a little while ago so we're still in mixed mode. Right now, i have to set permissions manually on each folder. Whenever i give permissions to someone to a folder and try to propagate, i can see the propagation dialog box and it shows that it's going to every subfolder, but the rights don't get copied. I'm sure it has to do with my being in mixed mode but there has to be...

Contracts in CRM 3.0/4.0
Hi! In CRM 3.0, the contracts you can create all depends on that they have been invoiced BEFORE allotments are made to the contract. In a service organisation, it's needed to create contracts that can be invoiced after allotments are made to it. Scenario: The customer calls in and has a problem with whatever. A Case is created and related to the contract. Activities are created to the case and completed. The Case is Solved and the allotments are made to the contract. At the end of the month, the contract and the allotments are invoiced to the Customer. How can I set this up? Best Rega...

Upgrade from CRM 3.0 to 4.0 fails with two errors
When running the upgrade from our App server that upgrade pops up with two messages, the first message when it is attempting to enable the Full Text Indexing. The Second error when it is trying drop the SQL v3 jobs. ANyone seen this or have a clue as to what is going on? Thank you for any help you can provide. 14:35:12| Info| Enable full-text indexing in MSCRM 14:35:12| Info| Enable full-text indexing in MSCRM 14:35:12| Error| System.Exception: Action Microsoft.Crm.Setup.Server.InstallDatabaseAction failed. ---> System.Reflection.TargetInvocationException: Exception has been thro...

Round Up and Round Down Time
Good Morning & a Happy New Year to all subscribers in this group. I want to round up Start times and round down Finish times to the next or previous 15 minutes in my spreadsheet. I have found MROUND but this does not work for me in all cases. There does not seem to be MROUNDUP or MROUNDDOWN available. I can get the results I want using a VLOOKUP table but is there another way? Regards to all, Dave Moore =FLOOR(A1,TIME(,15,)) =CEILING(A1,TIME(,15,)) -- David Biddulph DaveMoore wrote: > Good Morning & a Happy New Year to all subscribers in this group. > >...

GP 9.0 Certification
Hello from Las Vegas. I'm interested in becoming a Certified GP 9.0 user to enhance my career. I've looked at the Microsoft Guide to Certification and I'm sure I'm supposed to be going for the MS Certified Business Management Solutions Specialist (I think). I'm registered through CustomerSource and I'm a little confused on what courses I should take since I'm not an IT guy. Any help would be very appreciated. Shawn There is an accounting series of courses that covers foundation, GL, AR, AP, FA etc and another series that covers Inventory, POP, and SOP. You...

Upgrading to 9.0 on Windows Server 2003 64bit Edition
We are upgrading from 7.0 to 9.0. We have new SQL Servers on which we will perform the upgrade and move into production once complete replacing our existing servers. These SQL Servers are running Windows Server 2003 Enterprise x64 Edition. When attempting to install either GP v7.0 or v7.5 the error message "The image file ...\CDSetup.exe is valid, but is for a machine type other than the current machine." is presented and the installation script will not initialize. Is it possible to install GP 7.0 or 7.5 on the 64bit version of Windows Server 2003 or must we install the 32 bit v...

Statistic program for Exchange 5.5
Hi Is there anyone who can give me a hint for a good program for statistic for Exchange 5.5. What is importent for mee is to find out witch kind of attachment file the users had stored (avi, MPEG3 and so on) and how many MB - just totally??????? Speednissen ...

2.0
Currently I have one store with 1.2 Store Op and no service plan. I am opening another store in a few weeks with 2 lanes and I also need a HQ. Since I heard that 2.0 will not be shipping before March, what should I get? A 2 lane versions of 1.3 and a 1.3 HQ? If I get these 1.3s, do I have to upgrade the existing 1.2? Eventually I'd like to get everything upgraded to 2.0. whatever you do - version wise - everything will have to be on the same version otherwise the data will not flow between hq and stores. 2.0 is shipping from nex week in the UK so you shouldnt have any issues gettin...

Memory slot 0 in Windows CE 5.0
Hello, I have a doubt on Windows CE 5.0 Memory Architecture.... why is necessary to clone the SLOTn assigned to a process into the SLOT0 when the process is running ? Thanks, Paolo One of the reasons is the following: pratically each application uses one or more DLL; a DLL typically has some read only section (code) which can be shared between several applications and read/write section (data) which is not shared because it is different form application to application. The read only section is mapped at the same physical address for every application while the data reside i...