473,320 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Round function?

ORC
Is there a round function that do a "Normal" rounding and not the round to
nearest as the Math.Rounds is?

Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

but what I am looking for is a round function that returns 3.5 when rounding
the value 3.45 in the above. By the way The ToString does a normal
rounding - thank you Microsoft!

Thanks
Ole
Nov 16 '05 #1
3 23479
use
var a = Float.round(3.5);gives 4.0
var b = Float.round(3.4); gives 3.0
--
rajagopal

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
Rajagopal Pasupuleti <ra****************@yahoo.com> wrote:
use
var a = Float.round(3.5);gives 4.0
var b = Float.round(3.4); gives 3.0


Not sure which language you're using there, but if you mean Math.Round,
Math.Round (4.5) returns 4, so it's still using Banker's Rounding,
rather than the "normal" rounding the OP wants.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
public static double RealRound(double d, int decimals)
{
return Math.Round(d + decimals/10.0, decimals);
}
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"ORC" <or*@sol.dk> wrote in message
news:Ol**************@TK2MSFTNGP15.phx.gbl...
Is there a round function that do a "Normal" rounding and not the round to
nearest as the Math.Rounds is?

Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

but what I am looking for is a round function that returns 3.5 when rounding the value 3.45 in the above. By the way The ToString does a normal
rounding - thank you Microsoft!

Thanks
Ole

Nov 16 '05 #4

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

Similar topics

3
by: mg | last post by:
Hi everybody... We try to white scripts with Pyrhon 2.4 for an acoustic simulation and we wrote these follow lines : <begin script> c = 340 i =j=k= 1 sum_ = 23 table =
2
by: martin | last post by:
Hi, I see that there is not round function in vb.net as the vb one has been take out. my question is what is the best function to round a number variable to a given number of decimal places....
17
by: nomenklatura | last post by:
Hi, System.Math.Round function is confused me. for example i want to round 3.245 in with decimal symbol Result should be = 3.25 When i try to this in vb: A = 3.245 X = Round(A, 2) then...
9
by: Ronald W. Roberts | last post by:
I'm having a problem understanding the Round function. Below are quotes from two books on VB.NET. The first book shows examples with one argument and how it rounds. The second book something...
5
by: Marc | last post by:
Hi, I cannot get the round function to work on vb.net. I get the message that round is not declared? Has round function changed or something? MsgBox(round(3, 3))
3
by: sachindra manoj | last post by:
what is the header file when we are dealing with round function. or it haven't a header file,so you can tell me how we work with round function
8
dima69
by: dima69 | last post by:
May be somebody can explain to me how Round function works in Access. This article claims VBA6 uses banker's rounding, which means that exact half rounds to the closest even digit. This article...
2
by: dkruger | last post by:
Hi Everyone, I am having a little problem that I am hoping someone can help me out with. In one of my scripts, I am working with some dollar values, and using round to change the result...
1
by: RiK ooo | last post by:
Hi, i'm currently working on C# project and I want to make use of the Math.Round() function to display only the first to digits of a float value. Unfortunately this doesn't seem to be working for me....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.