Hi,
System.Math.Rou nd 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 x=3.24 , result is is false
But when i try to A = 3.235
X = Round(A, 2)
then x=3.24 , result is true
So how can i trust this function.
Or are there any true round function which you know?
Not: Normally , I want to round with two decimal place (>=5 is round up, <5
is round down) 17 5655
Nomenklatura,
I think you can trust the Round method to always act according to the
documentation:
"If value is halfway between two numbers, one of which is even and the other
odd, then the even number is returned."
"The behavior of this method follows IEEE Standard 754, section 4. This kind
of rounding is sometimes called rounding to nearest, or banker's rounding."
Kerry Moorman
"nomenklatu ra" wrote: Hi, System.Math.Rou nd 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 x=3.24 , result is is false
But when i try to A = 3.235 X = Round(A, 2) then x=3.24 , result is true
So how can i trust this function. Or are there any true round function which you know? Not: Normally , I want to round with two decimal place (>=5 is round up, <5 is round down)
Kerry, "If value is halfway between two numbers, one of which is even and the other odd, then the even number is returned."
"The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding."
I am curious where this is used beside banking.
Is this standard used in your country and when yes, from what country are
you?
Cor
"nomenklatu ra" <il******@opera mail.com> wrote in message
news:eV******** ******@TK2MSFTN GP10.phx.gbl... Hi, System.Math.Rou nd 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 x=3.24 , result is is false
But when i try to A = 3.235 X = Round(A, 2) then x=3.24 , result is true
So how can i trust this function. Or are there any true round function which you know? Not: Normally , I want to round with two decimal place (>=5 is round up,
<5 is round down)
In this instance, add 0.005 and truncate. I would suggest writing your own
round function to handle various decimal places (e.g., MyRound, or
whatever).
"squig" <sq************ @midsouth.rr.co m> wrote in message
news:KN******** ***********@fe2 .columbus.rr.co m... "nomenklatu ra" <il******@opera mail.com> wrote in message news:eV******** ******@TK2MSFTN GP10.phx.gbl... Hi, System.Math.Rou nd 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 x=3.24 , result is is false
But when i try to A = 3.235 X = Round(A, 2) then x=3.24 , result is true
So how can i trust this function. Or are there any true round function which you know? Not: Normally , I want to round with two decimal place (>=5 is round up, <5 is round down)
In this instance, add 0.005 and truncate. I would suggest writing your own round function to handle various decimal places (e.g., MyRound, or whatever).
One caveat -- be careful using FormatNumber since it returns a character
string rather than numeric. If you have to do further computation with your
(rounded) number, you will need to convert it back to a numeric.
I am in Turkey.
We pass new Currency unit at new year.. (TL->YTL). http://www.ytl.gen.tr/ytl/index_eng.php
The Ministry of Finance want to round this format..
That is not important odd or even..
And still i couldn't use round function..
"Cor Ligthert" <no************ @planet.nl>, iletide şunu yazdı
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
nomenklatura,
It appears that VS.NET 2005 (aka Whidbey, due out later in 2005) adds
overloads to Math.Round to support current "banker's rounding" or the more
conventional "round up". http://msdn2.microsoft.com/library/ef48waz8.aspx
Otherwise as squig suggests you probably want to create your own rounding
routine if "banker's rounding" is not appropriate for your routine...
Hope this helps
Jay
"nomenklatu ra" <il******@opera mail.com> wrote in message
news:eV******** ******@TK2MSFTN GP10.phx.gbl... Hi, System.Math.Rou nd 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 x=3.24 , result is is false
But when i try to A = 3.235 X = Round(A, 2) then x=3.24 , result is true
So how can i trust this function. Or are there any true round function which you know? Not: Normally , I want to round with two decimal place (>=5 is round up, <5 is round down)
i solved with FormatNumber functions
thanks all
"nomenklatu ra" <il******@opera mail.com> schrieb: System.Math.Rou nd function is confused me.
In addition to the other replies:
How To Implement Custom Rounding Procedures
<URL:http://support.microso ft.com/?scid=kb;EN-US;196652>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
That is round-toward-even and I wish everyone would use it (it is more
accurate). Unfortunately, it is even harder than converting people to metric
systems. :( This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ORC |
last post by:
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!
|
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 different.
Programming Microsoft Windows with Microsoft Visual Basic.NET
"The Round method with a single argument return the whole number nearest
to the argument. If the argument to Round is midway between two whole
numbers,
|
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))
|
by: shashiramu |
last post by:
Hi there,
Am trying to round a value 36.825 to 36.82,
But if i use ROUND function it is giving me 36.83
so can anyone help me in getting the value i needed
Thanks in Advance
Shashi
|
by: josh logan |
last post by:
Hello,
I need a round function that _always_ rounds to the higher integer if
the argument is equidistant between two integers. In Python 3.0, this
is not the advertised behavior of the built-in function round() as
seen below:
0
2
2
| |
by: Maric Michaud |
last post by:
Le Monday 28 July 2008 02:35:08 Herman, vous avez écrit :
Hmm, I don't have the same result in python2.6, I suspect it's a floating
point precision problem, try just to type "0.5" in the console to see the
exact representation of this value on your system, it may be just over or
just down by a small quantity.
On mine with 2.6 this typically give :
...: 0.5
|
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. I haven't much experience in using the Timer class or the Math class. I may be overlooking something stupid and the solution is probably really simple (happens a lot to me).. here's the piece of code..
//Retrieve time and round it off.
...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |