|
Great Peter!
I read the document,
a few more comments,
1.
"The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors." -- I do not agree no rounding error conclusion. Remember we discussed the case when data is realy too large/small which is out of range of Decimal, and the case of infinite numebr like 1/3? Any comments?
2.
"The binary representation of a Decimal value consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the 96-bit integer and specify what portion of it is a decimal fraction." -- Decimal frantion means the right part of a decimal (right part of the decimal point)?
3.
"binary integers (whole numbers)" -- you mean the whole number (except the decimal point used to scale), for example, 123.456 is stored as base 2 form of 123456 with a scale factor of 3?
Binary integers means integer represented in storage in base 2?
(really sorry for my so many questions, my English is not very good and I am really interested to discuss with you.)
regards,
George
|
|
|
|
|
Hi again!
1. I agree. Like I noted before, there will always be round-off errors as some values can never be represented exactly in any (non-infinite) precision. The Microsoft person who wrote "no round-off errors" probably should have written "no round-off errors caused by conversions between base 2 and base 10" - perhaps he did and some editor cut it down, you never know...
2. Exactly. I think "fraction" is from Latin or Greek, meaning something like "not whole" or "part". The opposite of "integer"/"integral". The value 123.456 consists of an integral part (123) and a fraction (.456).
3. Exactly. 123456 is stored like 11110001001000000. The scaling factor (3, stored as 11 binary) tells us that when the number is converted back to it's decimal representation (123456), the last 3 digits belong to the fraction.
No problem with the many questions - I'm Swedish myself, so I recognize your situation - thirty years in this business does miracles with your English, though, so hang in there! However, I can't promise I'll always have time to answer - but because I find a lot of useful articles here and have professional use for them, I try to spend some time looking for stuff that I can answer - just to give something back to the community.
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
It is cool, Peter!
Any other more dedicated forums or newsgroups for discussing about numberic topics to refer? Sometimes, I feel this forum is more for discussion of pure C# programming engineering topics.
regards,
George
|
|
|
|
|
George_George wrote: Any other more dedicated forums or newsgroups for discussing about numberic topics to refer?
On CodeProject, that would be the Mathematics and Algorithms[^] forum. Haven't googled for similar boards elsewhere.
If it's stuff related only to the .NET Framework types (not specifically C#, the System.Decimal and other types we have discussed are the same regardless of language), the .NET Framework[^] forum would be a logical choice.
My best,
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
Great Peter!
I have found something interesting related to the topic to share here.
http://en.wikipedia.org/wiki/Rounding[^]
It is mentioned "For example, if an integer divided by 7 is rounded to an integer, a computational rounding error up to 1/14 in the division (which is much more than is possible in typical cases) does not affect the outcome." -- I am confused. I think the rounding error should always be from 0 to 0.5, why the rounding error is up to 1/14?
regards,
George
|
|
|
|
|
Hi all,
i am developing a application for ANPR system. My appliaction using thread pool.registerwaitforsingleobject to grab the frames per 40 msec and signal the other thread for processing the frame. My appliaction has crashing becuase of out of memory error. i am running this appliaction in a hi-spec computer. please find my source below.
Main thread
{
Grabframe gf = new Grabframe();
gf.run();
manualresetevent anprevent = new manualresetevent(false);
.. create instance for anprclass anprobj
anprprocessthread(anprobj.run);
anprprocessthread.start();
}
class Grabframe
{
void run()
{
manualresetevent me = new manualresetevent(false);
waitortimercallback thread_method = waitortimercallback(grabframe);
Threadpool.registerwaitforsingleobject(me,thread_method,stateobj,40,false);
me.set();
}
void grabframe(object state,bool timeinterval)
{
...grab the frame
//signal anpr thread
anprevent.set();
}
}// end class grabframe
//anprthread
class anpr
{
void run()
{
anprevent.waitone();
..do anprprocess
.. get frame from global
}
}// end anpr class
Actually i have tried to reset manualresetevent on threadpool obj 'me' and my application didn't crash but the performance of the anpr is dropped.
please provide me suggestion as soon as possible.
Thanks.
sumathi
|
|
|
|
|
sumathi pandarinathan wrote: My appliaction has crashing becuase of out of memory error.
This is likely related to GDI+ issues. Investigate that code.
|
|
|
|
|
Hi,
i have found the line which is causing out of memory error.
please find the below program and it working similar my application.
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///
class testclass
{
public void show(Object O)
{
Console.WriteLine("Welcome to C#", "TestClass1 Object");
}
}
class testclass1
{
public void show(Object O)
{
Console.WriteLine("Welcome to ThreadPool", "TestClass2 Object");
}
}
class Example
{
static int CountDown= 20;
public static void WaitToShow(Object Obj, bool signaled)
{
if (Obj != null)
Console.WriteLine(CountDown--);
}
}
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
//AutoResetEvent MyEvent = new AutoResetEvent(false);
ManualResetEvent MyEvent = new ManualResetEvent(false);
testclass t1 = new testclass();
testclass1 t2 = new testclass1();
ThreadPool.RegisterWaitForSingleObject(MyEvent, new WaitOrTimerCallback(Example.WaitToShow),t1,40,false);
//ThreadPool.QueueUserWorkItem(new WaitCallback(t1.show));
//ThreadPool.QueueUserWorkItem(new WaitCallback(t2.show));
MyEvent.Set();
Console.WriteLine("****CountDown Program******");
Thread.Sleep(10000);
Console.ReadLine();
}
} // end clas
}
In the above example program, i commented the line " MyEvent.Set();" and doesn't gave me out of memory error. but if i didn't comment it then the appliaction getting crashed.
Actually i need to set manualresetevent, since the performance is very good.
please suggest me any solution for how to avoid increasing memory when i set manualresetevent.
Thanks.
Sumathi
|
|
|
|
|
How do i rename the buttons on a folderbrowserdialog?
|
|
|
|
|
You cannot. You have to build your own custom dialog inheriting from the CommonDialog[^] class.
|
|
|
|
|
You can not rename buttons on folder browser dilaog
|
|
|
|
|
I attended the VS2005 Launch Event and I was told there that with this control, new in 2.0, it was possible to prevent user from uploading a file that is too big.
I can use that feature in my website, but all I could find was the myUploadControl.PostedFile.ContentLength property which is only available AFTER the file has been uploaded.
Of course it would be very stupid to wait untill the user has uploaded his oversized file and then saying "sorry you can't upload this file, it's too big"...
Now I have the problem that, when the user selects e.g. a 5mb file he gets a "page cannot be displayed" instantly because 5mb exceeds the default limit of 4mb in asp.net.
I only want to allow a user to upload files that are maximum 2mb, if he selects a 3mb (or even 4gb) file I want to give him a message that the selected file is too big.
How can I accomplish this ?
|
|
|
|
|
Unfortunately on the server side, in ASP.NET, you can't tell the file size before the request is fully uploaded to the server, because the ASP.NET pipeline is invoked only at that time. When a file is greater than 10 MB (default), the request is killed by the ASP.NET runtime.
I am not aware of any client-side method available for determining the file size, unless you want to use Flash.
|
|
|
|
|
Dario Solera wrote: Flash
Or an ActiveX Control
Or a Java Applet.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I am trying to retrieve the all the cells selected by user in the worksheet of Excel using C#. Can anyone help ?
|
|
|
|
|
Varad_Rajan wrote: I am trying to retrieve the all the cells selected by user in the worksheet of Excel using C#.
Why dont you just ask the user? Seriously, without giving us even a hint of what you are doing, will not get you an answer.
|
|
|
|
|
I want to detect if a key is held down during the start up of my program, i.e. in
static void Main()
Is this possible to achieve? I want to make a safe mode that will be entered if the user holds down the shift key when starting the program.
|
|
|
|
|
|
One way I can think of is to add a reference to System.Windows.Forms if you don't have it already and use the following:
static void Main(string[] args)
{
Keys modifiers = Control.ModifierKeys;
Console.WriteLine(modifiers);
}
The modifiers enumeration will have the keys held down (only works for the modifier keys, i.e. Control , Shift , Alt etc).
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Thanks! This works like a charm!
|
|
|
|
|
Hello everyone,
Is Concole.WriteLine and other Console write methods, like Console.Write thread safe? I can not find any related information from MSDN about the thread safety of this method.
thanks in advance,
George
|
|
|
|
|
George_George wrote: I can not find any related information from MSDN about the thread safety of this method.
Not directly, but it can be worked out from the documentation.
Console.WriteLine is a wrapper for Console.Out.WriteLine. Console.Out is an instance of a TextReader, and in the documentation for TextReader it says: "Thread Safety Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."
|
|
|
|
|
So great, Colin!
regards,
George
|
|
|
|
|
|
Thanks Dave,
Your reply is very clear.
regards,
George
|
|
|
|