|
Hi Guys,
I've got a problem rounding floats, when adding a small value repeatedly to another, eventually small errors creep in.
float test = 0;
float increment = 0.2f;
for (int i = 0; i < 100; i++)
{
test += increment;
}
if (test != increment * 100)
throw new ApplicationException("Rounding Error!");
What are the available options to get around this?
regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
The Ethically Correct Answer: Floating point arithmetic usually comes with errors because of the representation of the significand. A good understanding of floating-point number representations can assist you in finding a good solution for your problem. Try reading What Every Computer Scientist Should Know About Floating-Point Arithmetic[^].
The Unethical Answer: If you would rather take the myopic path and just get a solution, change your float s to decimal s.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Awesome, cheers.
Have no fear, no WTF's from me, i need to understand how stuff works, so i'm going to go with option A.
Cheers for the pointer
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Most computer floating-point types can only precisely store integer multiples of powers of two; the size of the integer varies with the floating-point type. For example, even a single-precision float can precisely store the value 1/2, 5/16, or even 16,777,215/633,825,300,114,114,700,748,351,602,688 (that's (2^24-1)/2^99). Unfortunately, just as a decimal representation of numbers that do not factor into a power of ten will be an approximation (1/3, for example, may be written as 0.33, or 0.3333333, but neither is entirely precise) so too with binary representations of factions other than powers of two.
Depending upon what exactly you are doing with your data, it may be useful to re-scale values. For example, if everything will be a multiple of 0.01, you should scale your numbers up by a factor of 100. A single can store precisely any integer up to 2^24, and a double can store any integer up to 2^48.
|
|
|
|
|
I've just run NGen on an .exe assembly, to install, and it says all is up to date, but there is no Native Assembly folder in the GAC, nor is there any Native Assembly service. What's up?
|
|
|
|
|
I installed the same provider and oracle client at my local machine and production server. I am able to connect to oracle database through my machine but I get this error when I execute the same code on server.
Oracle.DataAccess.Client.OracleException . The provider is not compatible with the version of oracle client.
The production server is Window server 2003
I need to sort this out ASAP.
Can anybody help me.
|
|
|
|
|
Hello,
I am looking for the methodology to develop the program (preferably webservice) to allow the multiple users on the LAN , to have the certain permission based access on the storage media (like westren digital mybook that connects to the usb port of the computer) ,
so that every user has a purticular quota on the storage media and no body else can access
their folder as well.
need some guidence in this regard.
|
|
|
|
|
hello friends,
i am developing an application which read all the bounce emails in the ms-outlook.
1) i configured my ms-outlook with rediffmailpro.com and sent a email with invalid email-id i got bounce/failured mail back in response of it.
but my original message comes into .msg file. why?
2) i configured my ms-outlook with gmail.com and sent a email with invalid email-id i got bounce/failured mail back in response of it. but my original message doesn't came into .msg file. why?
why these 2 configureation are differnet? please help.?
Regards,
Shakil.
Shakil.
Softwared Developer Team,
Mumbai-INDIA
|
|
|
|
|
It has to do with the way the mail server handles the bounce. Sometimes they include the message inline and sometimes they add it as an attachment. Sometimes the attachment has an .msg extension, sometimes it has a different attachment. Unfortunately, if you don't control the mail server, you can't control the way that they will return to you.
Curtis.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hi all
what does Increment method of the performancecounter class
do ???
what does it increment ?? time step ??
|
|
|
|
|
"Increments the associated performance counter by one through an efficient atomic operation."
Source[^]
I are troll
|
|
|
|
|
Hi all, What are all the content involved in Content Management system? For ex, .Net contains Xml, linq, sliverlight, ado.net etc.. like that.
Thanks in advance.
|
|
|
|
|
A content management system manages content, not source code. From a dictionary Web site, one of the meanings of "content," the most applicable here, methinks, is "The material, including text and images, that constitutes a publication or document."
Now, if content consists of text and images, things like XML, LINQ, Silverlight, and ADO.NET don't really fit into this. You can build a content management system with any and all of those technologies, but they are not the content.
If you'd like to learn about content management systems in the .NET world, you can refer to MojoPortal[^] or DotNetNuke[^]. Those are relatively mature content management systems in the open source space. Ostensibly, that means that you can dig through the source and figure out how a content management system works, why it works the way it does, and (most importantly) WHAT comprises a content management system.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Start out with a Definition Study
I are troll
|
|
|
|
|
Exactly what I wrote but so much more concise!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
modified on Friday, February 27, 2009 10:49 AM
|
|
|
|
|
|
My penchant for pedagogy sometimes overrides my common sense. What do I know? <smile />
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I m totally confused in PrincipalPermission Class, i tried to read details on mcdn but no use, can plz any1 tell me abt this class.
MSDN says " Allows checks against the active principal (see IPrincipal) using the language constructs defined for both declarative and imperative security actions. This class cannot be inherited. "
i m not getting
checks
active principal
language constructs
thanks in advance.
|
|
|
|
|
Basically, Active Principal is the security context for the current user.
It says that security verifications can be made in 2 ways:
declarative - in this case the security checks are implemented using attributes.
Take a look here for Declarative Security[^]
imperative - in this case the security checks are made in code.
See this[^] for Imperative Security.
Calin
|
|
|
|
|
Hi guys,
I need links regarding to dotnet projects for my own praticle please help me on it.
Buy!!!!!!!!!!!!!!1
|
|
|
|
|
Hi guys,
I need links regarding to a million dollars for my own wealthle please help me on it.
Sell!!!!!!!!!!!!!!1
|
|
|
|
|
|
First, it's called Google. Do a bit of research. We are not your coding b*tches.
Second, read the forum guidelines so you understand to STOP YELLING.
|
|
|
|
|
leckey wrote: We are not your coding b*tches.
SPEAK FOR YOURSELF!
leckey wrote: STOP YELLING.
NO!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|