.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

doubles being miscalculated (rounding errors?)

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :.NET Framework

I'll try to keep this short and to the point.  I'm not exactly sure which forum to put this in.

Generally, if you add two doubles, say 1.3 and 2.5, you get a sensible answer (3.8).  In my program, this works as expected, until I open a certain form.  Once it's been opened, doubles go crazy throughout the whole application.  Here are some examples of results I get after opening the form (these results were computed on a separate form):






So most numbers become corrupted.  Okay but it's even more complicated than that.  If I write the values to a textbox, the output may or may not be corrupted, depending on if the numbers are assigned:

 a = 1.3;
 b = 4.5;
 c = a+b;
textbox1.text += a.tostring();
textbox1.text += "\r\n"
textbox1.text += "\r\n"
textbox1.text += "\r\n"

View Complete Post

More Related Resource Links

How can I be sure that my entire project is up-to-date and free of errors in VS2010?


Seems like a stupid question, but I will go to Build > Build Solution many many times and the build will succeed many many times, then I will put in a minor syntax error and the build will fail, BUT the build will not fail because of the minor syntax error; it will fail because of an unresolved type that I put in about twenty compiles ago. And then I will fix the minor syntax eror, and the compiler will still complain about the unresolved type. Here is my code:

<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
  <form runat="server">
  Hello World!!  

Pretty simple, really. I go to Buld > Build WebApplication1 and it runs OK. Now, if I put in a minor syntax error, such as substitute "forrrrrrrm" for "form" and then try to Build Solution, it complains not about the misspelled word, but about the FreeTextBox. And then if I correct the misspelled wird, it still complains about the FreeTextBox. Which leads me to believe that Building the Solution does not check absolutely 100% everything that needs to be checked. Is there a more thorough way of compiling a program that I need to use?

Word Automation - Multiple DCOM Errors/Behavior

Before I get started, I already know that Microsoft does not support and highly discourages server-based MS Office automation.  I've read a multitude of posts and smarmy "*wink*, here's a link" replies, so I'm looking for actual help here, not condescending reprimands.

That notwithstanding, here is my problem.  I have developed a simple method that will open a local Word document, modify some header information, and then save the document as a new file.  As expected, it works great as a console/windows app, but as soon as I went to ASP.NET, DCOM jacked my world up when accessing the app remotely from a different domain account (that has access to the ASP.NET app.  For reference, my method is shown below:


1    public static string ModifyAndSaveBuildDocument(string localFilePath, BuildDocumentType docType, string buildNumber, DateTime buildDate, string projectName)
2            {
3                try
4                {
5                    ProjectConfiguration config = (ProjectConfiguration)ConfigurationManager.GetSection("ProjectConfiguration");

Toolbox: Logging Web App Errors, Learning LINQ, and More


See how to log Web application errors for better health monitoring, what to read if you're thinking about LINQ, and which blog Scott recommends reading this month.

Scott Mitchell

MSDN Magazine April 2008

Unit Testing: Exploring The Continuum Of Test Doubles


Creating and using mock component servers simplifies unit testing. Use these examples to get started.

Mark Seemann

MSDN Magazine September 2007

Enterprise Library: Take Exception To Critical Errors With Custom Application Blocks


Enterprise Library is a collection of application functionality blocks that you can re-use in your application for common functionality you'd otherwise have to write again and again. Here Jay Hilyard explains how to use them.

Jay Hilyard

MSDN Magazine September 2006

Toolbox: Synchronize Data, Review Runtime Errors, and More


This month we bring you products that let you synchronize data, correct runtime errors, and more.

Scott Mitchell

MSDN Magazine August 2006

ASP.NET MVC3 Areas and Razor views produce errors?


The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List. It does nothing except:

public ActionResult Index()
    return View("~/Areas/SomeArea/Views/List/Index.cshtml");

The view looks like:

@inherits System.Web.Mvc.WebViewPage<dynamic>
    View.Title = "Index";
    LayoutPage = "~/Views/Shared/_Layout.cshtml";


I have tried emptying the entire file part by part and nothing seems to help. If I create a controller and view outside the area it works just fine. If I create an aspx view it works fine as well. Is it possible the default razor view engine doesn't support areas at this time?

The areas are registered too.

public static void RegisterRoutes(RouteCollection routes)
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters

Think that there is actually errors in ajax toolkit for 2.0 framework...hmm


Im using VS2008, asp.net C# 2.0.


Recently i tryed to correct some stuff on my page and i had a friend to take a look at the stuff...


What i did was that i have Examples page with code examples. Then accordion panes for each code piece...And syntaxhighlighter for each code piece. The code that i presented is read from the txt files wich makes it easyer for me to put new examples on the site...

But the problem is now that two of my accordion panes are not working...and everything works in all other browsers this just happens in Internet Explorer. This is kind of weird and my friends explaination was that there is actually errors in the ajax toolkit dll.


Im using the latest version of ajax toolkit for framework 2.0 wich is 1.0.20229.

My friend said its actually amazing that the toolkit has been out there for that long and it has not been tested that well and that there i still errors in it.


You can test this by your self by doing the exact as i explain:


go here: http://www.simpa.dk/Examples.aspx?cookieCheck=true

click Csharp

and try to open the accordion that is from the bottom 2 or 1 they dont collapse...

but this works in all other browsers then Internet Explore

Validation errors and getting the site disability accessibile


I'm using the official validator from the World Wide Web Consortium, http://validator.w3.org/

And I'm seeing a lot of validation errors. What can be done to make my sharepoint publishing site a little more accessibility friendly?


Reporting Services in SharePoint integration - configurtion errors in 64bit version



We have build an MOSS 2007 environment on 64 bit servers. We build the reporting services server and configured in SharePoint integration mode. Initially configuration looks fine with reporting services integration with green indicators.


After creating a web application and accessing the web site from the report servor, i have found the following errors:


Server Error in '/' Application.

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'RSSharePointSoapProxy, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot fi

Moss 2007 Document check out and check in errors


Users are receiving errors when trying to check in documents.


"The Web server is busy. Try again later."


"This document was checked out to your local drafts folder but the local copy could not be checked in to the site. Close any application that is editing the document and try to check in again, or discard the checkout."


"There is a problem with the Web server. Try again later, or contact the server administrator."

Workstation has office 2007, upgraded from 2003. Documents are being checked out, edited, and checked in properly. Any help appreciated. Thanks.

Errors checking documents out


Dear all

I've recently had SharePoint set up and I've created my first shared document list. I changed the settings to switch on checking out and I'm now getting errors. The error occurs when I click OK on the 'you are about to open...' dialogue with 'edit' selected. The error comes up in a new box and it states 'object reference not set to an instance of an object'. When I click OK it gives a message stating I may not have permissions or that the file is currently checked out by someone else. I have permissions to the whole site so I don't think that is the problem, and I know for sure that the files are not checked out (i tested this by uploading a new file and trying to check it out).

Many thanks in advance for comments and suggestions.


Errors when interacting with WorkFlow generated tasks through ISA Server


I have a MOSs environment that I have published through ISA Server 2006 and i am getting really strange behavior whentrying to interact with WorkLFow generated tasks when I have connected through ISA. This also seems to affect InfoPath Forms Services. I was wondering if anyone out there is seeing any problems when using ISA Server to interact wih Forms or WorkFlows?


The error I get simply states:

the form cannot be submitted to the web server either because your computer is offline or because the host server is currently unavailable.


Any help would be appreciated.





Rounding a number based upon it's midpoint


I need to round down, or round up a floaitng point number to it's closest integer value.
So for example 3.49999 is closer to 3 so it would round down to the integer 3.
3.5002 is closer to 4 so this would round up to the integer 4.

I do not need to be concerned negative numbers. Can someone show me how to do this?


Here are more examples to make clear what I am talking about



UserControl, CustomControl Design Time Support errors IOC, Dependency Injection, MVP

  Hi, is there a way to completely disable design time support for CustomControl, and UserControl ? I have about 30 UserControls and 10 CustomControls in my WinForms app, which contains some Dependency Injections and IOC stuff in constructors and Load handlers. I have lots of large UserControls containing smaller UserControls (CompositeView). All my UI code is pretty dynamic and the only thing i need to do at design time is to drag&drop containers in other containers (UserControls). And now i have a hard time doing this, because i have to wrap all constructors and Load Handlers in CurrentProccess!="devenv"... and when I'm Implementing some new View interface (which consist lots of properties) in UserControl all those properties by default throw NotImplementedException and i don't always need to implement them immediately but still i need to be able to run this code for testing. Besides, then i have to clean up designer generated class because it adds unnecessary null value property initializations, and then it way add some other ____ code, and so on.... Imagine UserControl with 10-15 nested UserControls, and then i try to open it in Form Designer and get ObjectReference NULL exception (for IOC) or some NotSupported NotImplemented exceptions (for properties) without adequate CallStack available! There is a CallStack but there is no trace in it to my Code (

To prevent possible data loss before loading the designer, the following errors must be resolved: In

To prevent possible data loss before loading the designer, the following errors must be resolved: The class Form can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again. Instances of this error (1) 1. Hide Call Stack at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) Thanks! This post is from Matthew Cenance.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend